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
hi
After printing "hi" once, nothing happens anymore.
Any ideas why?
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.
(source)
Use >>
instead to append to the file.