Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

linux - Crontab is not working on Amazon EC2 server

Crontab is not working on Amazon EC2 Linux Server.

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

I have started crontab command already, but this one didn't work.

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?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved the problem.

I used this code and it works!

* 2 * * * root tar cvfpz /home/backup/web_`date +\%Y\%m\%d`.tar.gz /home/web

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...