Jump to content

Recommended Posts

Posted

Still new at cron jobs / unix command line so go easy. Whats the most efficient way to run a php file through the crontab. The php file i plan to execute resets a certain counter in my database, i want to have this done weekly. I've come up with

 

>00**0 lynx -dump http://www.torrentlinks.com/reset.php

 

However, I'm not sure if there is an easier way than using the lynx browser...is there?

 

If someone could give me a nice site on sample crontabs that would help a bunch...

 

Thanks,

Dave

Posted

check out this link... http://www.faqts.com/knowledge_base/view.p...id/1005/fid/436

 

something tells me you might not have to run it through a browser.

 

you could do something like this...

 

>> crontab -e

(within the editor)
00 12 1 * 0 0 /home/youracct/path/to/yourscript.php

 

BUT, and this is a big but... only do this if you know what you are doing! i have never used a cron job before, so I could have told you the completely wrong thing to do!! I got my info from that site and the crontab man page

 

chuck

Posted

Not exactly true.

 

PHP scripts can indeed be run from the command line or by a cron job. I'm not sure if the TCH servers are set up to allow this or not -- not sure if our cron jobs can access /usr/bin/php or not. Without shell access to experiment with the results I'd be rather wary to experiment with this.

 

From the PHP manual:

http://www.php.net/manual/en/features.commandline.php

However, there's another way of using PHP for shell scripting. You can write a script where the first line starts with #!/usr/bin/php. Following this you can place normal PHP code included within the PHP starting and end tags. Once you have set the execution attributes of the file appropriately (e.g. chmod +x test) your script can be executed like a normal shell or perl script:

 

#!/usr/bin/php

<?php

    var_dump($argv);

?>

Posted

I am actually trying to run a php script from the cron. I've tried the "shell script" example and this one:

 

* * * * * php /home/yadda/public_html/test.php

 

It works alright, but it sends an e-mail from the Cron every time it executes. (it's doing it every minute for testing purposes only) Does anyone know how to prevent the e-mails?

 

The e-mail contains:

 

Content-type: text/html

X-Powered-By: PHP/4.3.1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...