How to stop and restart Crontab service when something is wrong

How to stop and restart Crontab service when something is wrong


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.

MobaXterm_2018-10-27_18-25-20.png

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 * with 0.

0 18 * /home/ubuntu/miniconda3/bin/python /home/ubuntu/vornix_posting_bot.py >> /home/ubuntu/logs/vornix.log 2>&1

  • Secondly, changing the crontab file itself is not enough to stop crontab service to keep executing the old command which is repeating every minute and I have no idea when it will be ended. Restart the 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’

    Your browser is out-of-date!

    Update your browser to view this website correctly. Update my browser now

    ×