Cron job to execute a PHP program

試著忘記壹切 提交于 2019-12-12 01:36:59

问题


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 to know the command of cron job to execute the program on every day automatically. I have no knowledge of Linux commands.


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/4905605/cron-job-to-execute-a-php-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!