I defined crontab job by means of:
sudo crontab -e
As I can see it is listed when I type:
sudo crontab -l
and it's listed as well when I type:
run-parts --test /etc/cron.monthly
Than I modified script (only script content, without it's name). My script send an email and I modified email content.
Unfortunately, for some reason previous version of my script is executed (I receive and old email). I even restarted cron:
sudo service cron restart
but it doesn't help. I've tried to remove and add again mentioned script to cron, but it doesn't help as well.
I use Ubuntu 12.04.4 LTS
I had same issue on Ubuntu 18.4 LTS.
Cron kept old version of my script and didn't seem to see the script was updated.
Solved this by doing
sudo service cron stop
and thensudo service cron start
.sudo service cron restart
didn't do the trick.It seems strange that the script is listed with the
run-parts
command in/etc/cron.monthly
, that suggests that the script is somehow in that directory.Perhaps you have a copy of the old version in the
/etc/cron.monthly
directory?It may be worth removing the crontab entries, and checking that there's nothing in
/etc/cron.monthly
, then try renaming the script and putting it back in your crontab to see if it executes correctly.If it does work correctly, you can try to change the name back afterwards.
Do a file search as 'root' and locate all instances of your script. Remove all those you do not want. When you have only the version of the script you want to run through cron, then restart cron.