服务器有Ubuntu 12.10,我尝试安装cron
:
sudo apt-get update
sudo apt-get install cron
第二个命令的输出:
Reading package lists... Done
Building dependency tree
Reading state information... Done
cron is already the newest version.
The following package was automatically installed and is no longer required:
php5-common
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
然后,当我尝试sudo /sbin/chkconfig crond on
时:
sudo: /sbin/chkconfig: command not found
sudo /sbin/service crond start
:
sudo: /sbin/service: command not found
crond
位于其他地方吗?或者,我会错过其他什么吗?
谢谢
编辑: ps -ef | grep cron
的输出:
root 716 1 0 May30 ? 00:00:15 cron
deployer 26036 25816 0 10:59 pts/2 00:00:00 grep --color=auto cron
答案 0 :(得分:2)
如评论中所示,并按照您提到How To Use Cron To Automate Tasks On a VPS的教程,这就是您错过的内容:
检查service
:
which service
当它返回/usr/sbin/service
时,你必须用它来启动cron:
sudo /usr/sbin/service cron start
这会向您返回start: Job is already running: cron
,因此它已在运行。通常,要知道它是否正在运行,您可以执行命令
ps -ef | grep cron
从现在开始,您的服务器上已运行cron
。您可以使用crontab -e
对其进行修改,并使用crontab -l
查看当前值。您可以使用虚拟* * * * * echo "hello" >> /tmp/test123
对其进行测试,它会每分钟在/ tmp / test123中写入hello
。如有需要,您可以在https://stackoverflow.com/tags/crontab/info。