本文介绍了Crontab 无法在 Amazon EC2 服务器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Crontab 不适用于 Amazon EC2 Linux 服务器.

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

有和我一样经历的吗?

谢谢.

推荐答案

我最近开始在 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 服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:46