Crontab 无法在 Amazon EC2 服务器上运行

编程入门 行业动态 更新时间:2024-10-27 22:24:36
本文介绍了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 服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-27 04:44:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/679114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器上   Crontab   Amazon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!