After I’ve completed my first working Python script, the last step was to automate the script execution in my Ubuntu server via crontab. As a Unix sysadmin I thought this was a piece of cake but I made a noob error somehow.
Used * in the minute column of entry
18 /home/ubuntu/miniconda3/bin/python /home/ubuntu/vornix_posting_bot.py >> /home/ubuntu/logs/vornix.log 2>&1
This was what I added in the crontab file with simple command just to execute the script and output errors into a log fine. The execution time was ideally plan to be at 1800 every day. Note that the first *
here was representing the minute.
Luckily I did not put the script into produection straight away as the next day I found out crontab was executing the command once every single minute.
Solutions
Huge mistake and here is what I have done to fix it:
- Apparently we need to fix the crontab syntax which is replacing the
*
with0
.
0 18 * /home/ubuntu/miniconda3/bin/python /home/ubuntu/vornix_posting_bot.py >> /home/ubuntu/logs/vornix.log 2>&1
cron
service by service cron restart
in Ubuntu OS and check the status with service cron status
. The previous job should be ended now.Posted from my blog with SteemPress : https://fr3eze.vornix.blog/how-to-stop-and-restart-crontab-service-when-something-is-wrong/
This page is synchronized from the post: ‘How to stop and restart Crontab service when something is wrong’