Amazon ec2 crontab在AWS EC2实例中不工作
我正在努力让AWS EC2实例(Amazon Linux AMI)中的crontab运行我的R脚本,因此我编写了一个非常基本的crontab,只是为了测试crontab是否在我的实例中工作:Amazon ec2 crontab在AWS EC2实例中不工作,amazon-ec2,cron,Amazon Ec2,Cron,我正在努力让AWS EC2实例(Amazon Linux AMI)中的crontab运行我的R脚本,因此我编写了一个非常基本的crontab,只是为了测试crontab是否在我的实例中工作: crontab -e * * * * * echo "Is this working" * * * * * echo "write to script" >> testfile.txt save the crontab 但是,这两个都没有做任何事情(终端中没有运行作业的输出/没有在我的主
crontab -e
* * * * * echo "Is this working"
* * * * * echo "write to script" >> testfile.txt
save the crontab
但是,这两个都没有做任何事情(终端中没有运行作业的输出/没有在我的主目录中写入新的文本文件)
如何让crontab在AWS EC2实例中工作
编辑:我试图在命令行中运行以下命令,但不起作用
sudo service cron start
cron: unrecognized service
编辑2:我还得到了以下信息
ps aux | grep crond
root 2694 0.0 0.0 121604 2580 ? Ss Jan10 0:00 crond
root 5491 0.0 0.0 110472 2044 pts/0 S+ 00:52 0:00 grep --color=auto crond
您可以为cron设置环境变量 您是否尝试检查以下环境变量
- 家
- 它表示cron用户的主目录。我猜它的定义是“/”
- 路径
- 它定义了cron用户的$PATH。请也输入这个变量
/etc/crontab
$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# 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