'Crontab doesn't execute .sh script in Amazon-EC2
I setted up a Cron Job in Amazon-EC2.
First, I edited the crontab:
crontab -e
Adding the following:
* * * * * /home/ubuntu/run.sh &>> /home/ubuntu/output.txt
* * * * * /usr/bin/uptime > /tmp/uptime
The content of run.sh is just
echo 123;
echo 321;
The uptime file is being updated with something like:
12:57:01 up 1:07, 1 user, load average: 0.00, 0.00, 0.00
However, the output.txt file remains empty.
Executing ps -ef | grep cron | grep -v grep returns:
root 440 1 0 11:50 ? 00:00:00 /usr/sbin/cron -f
And executing crontab -l outputs the content I added through crontab -e
Running run.sh with :~$ /home/ubuntu/run.sh &>> /home/ubuntu/output.txt appends output.txt file as expected.
Solution 1:[1]
Suggesting to modify your run.sh
#!/bin/sh
/usr/bin/echo 123
/usr/bin/echo 321
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dudi Boy |
