Crontab在Amazon EC2服务器上不起作用 [英] Crontab is not working on Amazon EC2 server
问题描述
Crontab在Amazon EC2 Linux Server上不起作用.
Crontab is not working on Amazon EC2 Linux Server.
我已将以下代码保存在/etc/crontab文件中
I have saved below codes in /etc/crontab file
crontab
# For details see man 4 crontabs
# Example of job definition:
# .---------------- 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
# | | | | |
# * * * * * user-name command to be executed
* 10 * * * tar cvfpz /home/backup/web_$(date +%Y%m%d).tar.gz /home/web
我已经启动了crontab命令,但是此命令不起作用.
I have started crontab command already, but this one didn't work.
我也将该行保存在"crontab -e"中,但是cron无法正常工作.
I also have saved this line in "crontab -e" too, but cron won't work.
* 10 * * * tar cvfpz /home/backup/web_$(date +%Y%m%d).tar.gz /home/web
有没有像我一样经历过的人?
Is there anyone who had same experience like me?
谢谢.
推荐答案
我最近开始在ec2实例上使用Amazon的Linux发行版,在尝试了cron的所有功能之后,我需要的是:
sudo service crond start
crontab -e
这使我可以将cron作业设置为"ec2-user",而无需指定用户.例如:
0 12 * * * python3 example.py
实际上,在此处指定用户会阻止其运行.
I recently began using Amazon's linux distro on ec2 instances and after trying all kinds of things for cron all I needed was:
sudo service crond start
crontab -e
This allowed me to set a cron job as "ec2-user" without specifying the user. For example:
0 12 * * * python3 example.py
In fact, specifying a user here prevented it from running.
这篇关于Crontab在Amazon EC2服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!