开发者

Cron job to execute a PHP program

I have a Linux server and in this I want to execute a cron job for sending birthday mail to all my friend with a PHP program. I want to create a php program that read data from database and send the mail.

I want t开发者_如何学Goo know the command of cron job to execute the program on every day automatically. I have no knowledge of Linux commands.


You will want to read up a little bit on the 'crontab' command but basically you will do this.

From a linux command prompt run the crontab command.

Then add this entry:

* * * * * php yourscript/path

You can set what time by modifying the * values. See this URL for information on that:

http://adminschoice.com/crontab-quick-reference


This is the command to add to your crontab file:

0 0 * * * /usr/bin/php /path/to/your/script.php

Adjust the paths to the PHP interpreter and your script as necessary. It will run your script every day at midnight.


This is done using a cron table in unix systems, including linux. Check out some example documentation:

  • http://en.wikipedia.org/wiki/Cron
  • http://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html

You'll find many more, if you google for crontab, or if you check out the man crontab pages on your linux box

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜