Reputation: 547
Another article describes that a way to test if cron is running is to create a crontab -e with this script:
* * * * * /usr/bin/uptime > /tmp/uptime
When i go check on the cron cat /tmp/uptime there is no result. The same goes with a test script with a direct path to php.
I'm running AWS running Amazon Linux.
I checked to see if cron was even running with chkconfig --list crond result:
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
UPDATE (based on comments)
[ec2-user@ip-xxx-xxx ~]$ service crond status
crond (pid 2844) is running...
[ec2-user@ip-xxx-xxx ~]$ ps aux | grep crond
root 2844 0.0 0.2 121636 2572 ? Ss Sep04 0:01 crond
ec2-user 7904 0.0 0.2 110468 2096 pts/0 S+ 22:46 0:00 grep --color=auto crond
Just to be safe I manually started cron with this command:
sudo service crond start
I've also tried sudo su and created instances both in ec2-user and root. Nothing seems to actually run the cron.
Does anyone have any suggestions? It seems that the docs on Cron elsewhere are several years old. Thanks in advance.
Reference:
Setting Up Cron in Amazon Linux AMI
Upvotes: 0
Views: 3578
Reputation: 2113
[ec2-user@ip-172-31-47-191 ~]$ sudo crontab -l
no crontab for root
[ec2-user@ip-172-31-47-191 ~]$ sudo crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[ec2-user@ip-172-31-47-191 ~]$ sudo crontab -l
* * * * * /usr/bin/uptime > /tmp/uptime
[ec2-user@ip-172-31-47-191 ~]$ /usr/bin/uptime
23:05:09 up 284 days, 12:52, 1 user, load average: 0.01, 0.02, 0.05
[ec2-user@ip-172-31-47-191 ~]$ ls -l /tmp
total 4
drwx------. 2 oracle dba 6 Sep 7 11:03 mc-oracle
drwx------. 2 root root 6 Sep 7 11:01 mc-root
-rw-r--r--. 1 root root 71 Sep 14 23:05 uptime
[ec2-user@ip-172-31-47-191 ~]$ more /tmp/uptime
23:05:01 up 284 days, 12:52, 1 user, load average: 0.01, 0.02, 0.05
[ec2-user@ip-172-31-47-191 ~]$ service crond status
Redirecting to /bin/systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-04-20 03:07:03 EDT; 4 months 26 days ago
Main PID: 16998 (crond)
CGroup: /system.slice/crond.service
└─16998 /usr/sbin/crond -n
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
[ec2-user@ip-172-31-47-191 ~]$ 191 ~]$
Upvotes: 0
Reputation: 1
Do the following:
sudo service crond reload
or
sudo service crond restart
This could happen to VPS server, after you do the crontab modification, you might need to reload it in order for the modification to take place. In the worse case scenario, the crond restart will stop the service and start it again. Hope that helps.
Upvotes: 0
Reputation: 3
Verify that procps package is installed (that package provides uptime command)
sudo yum install procps
Also verify that your cron job is saved
crontab -l
Upvotes: 0
Reputation: 126
have you check the cron daemon status ?
$ service crond status
crond (pid xxx) is running...
$ ps aux | grep crond
root 2533 0.0 0.1 119552 1784 ? Ss Apr04 1:57 crond
ec2-user 22203 0.0 0.2 110460 2084 pts/0 S+ 09:37 0:00 grep --color=auto crond
then, if cron daemon seems not running you can start it
$ service crond start
Upvotes: 2