Cron runs only once instead every minute
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04).
The /etc/echo.sh simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log 2>&1
/etc/init.d/cron reload * Reloading configuration files for periodic command scheduler cron [ OK ]
tail -f /var/log/cron.log
hiAfter printing "hi" once, nothing happens anymore.
Any ideas why?
22 Answers
The script does run every minute but > truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
Use >> instead to append to the file.
*/1 * * * * root /etc/echo.sh > /var/log/cron.log 2>&1I think that this is the problem. You must change the crontab minute option to */1 to run that bash every minute.