The*_*zoo 30
你有Windows机器还是Linux机器?
在Windows下,cron称为"计划任务".它位于控制面板中.您可以设置多个脚本在控制面板中的指定时间运行.使用向导定义计划时间.确保PHP在PATH中可调用.
在Linux下,您可以通过键入以下内容为当前用户创建crontab:
crontab -e [username]
Run Code Online (Sandbox Code Playgroud)
如果此命令失败,则可能未安装cron.如果您使用基于Debian的系统(Debian,Ubuntu),请首先尝试以下命令:
sudo apt-get update
sudo apt-get install cron
Run Code Online (Sandbox Code Playgroud)
如果命令正常运行,则会出现文本编辑器.现在,您可以将命令行添加到crontab文件中.每隔五分钟运行一次:
*/5 * * * * /home/user/test.pl
Run Code Online (Sandbox Code Playgroud)
语法基本上是这样的:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed
Run Code Online (Sandbox Code Playgroud)
在以下页面上阅读更多相关信息:Wikipedia:crontab
Eri*_*ski 13
在Linux/Unix上安装cron:
apt-get install cron
Run Code Online (Sandbox Code Playgroud)
在Linux/Unix上使用cron
crontab -e
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅有关cron的规范答案:https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it