All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Is It Normal That Cron Won't Run For A Cloned VPS (Hetzner) ?
Hello,
For some reason, I have to quick build a vps by cloning a previously works one at Hetzner Cloud. Its just a LEMP server with a few websites in it. The cron job was work with no issue at the previous vps - one of the main cron job is backup web files & database to my backup server on different provider.
After the new vps running (LEMP stack works), I deleted the previous (old) server. But after many days I noticed that the backup cron job was not run, I checked the very first step log and it shows nothing. It only run if I executed it manually.
Then I created a very simple bash script (insert / append current date to file) for testing purpose. And I found that simple script was also not run at all. I was also check if my root password has expired (if it has to do with this issue), use vi instead of nano, use crontab import from file etc but still, my cronjob wont run.
I then used systemd timer to replace crond only to discover that the simple scipt and even my backups were now running.
I don't have much knowledge of how Linux OS works especially in VM environment, is it normal that a cloned vps would have issue in cron/crontab ? How to fix cron/crontab job on a cloned vps ?
Thank you

Comments
There's no difference between VM and non-virtualized environment when it comes to cron scripts. Do you have execute bit properly set for the script? Are you running it with a proper user? Are the commands you run in PATH? Does cron log show that it is running? Is your crontab format proper? There are a lot of things that go wrong.
Accidental double post.
This is the cronjob for the simple script (both not work)
`* * * * * /usr/bin/sh /root/mycron/test.sh > /root/mycron/test.log
OR
This is the cronjob for the simple script (both not work)
`* * * * * /usr/bin/sh /root/mycron/test.sh > /root/mycron/testlog.txt
OR
This is the content of test.sh
`#!/bin/sh
echo -e
date> test.log`Put #!/usr/bin/sh to the first line of /root/mycron/test.sh and leave it out of crontab. The first example is not proper since you don't have the user specified. Does cron log at /var/log show that it is getting executed?
Yeah, i don't really know what's OP's definition of cloning but in general everything should just run after maybe adjusting network settings. I have a VPS that has been cloned (by mirroring the disk) across at least 5 VMs at 2 providers and it runs like on its first day.
Create VPS from a snapshot
Nothing as it hasnt even run.
Sorry for the typo, of course I put #!/usr/bin/sh at the first line. And dont forget that the script was running well on previous VPS.
Do you have execute bit on it? What does ls -al /root/mycron/test.sh show?
chmod u+x script.sh
There are journal log you can check
journalctl --no-pager --since <date-start> --until <date-end> -u cron | lessnote :
--no-pager : I hate the internal pager, prefer to pipe it to
less<date>: replace with 'yyyy-mm-dd 00:00:00', you can omit the time-u : unit name, in your case, it's cron related thing
Don't really know if there are errors will shown here extensively
Yes, I have executed it manually.
Of course the path is right.
Yes, I already make it executable.
I think maybe I'm just unlucky, the snapshot (instant image) was taken while the VM was running. Maybe somehow it got corrupted.
At least now my backups can be scheduled using systemd timer.
Have you checked
crondprocess is running?If you clone a system, sometimes service cannot start properly because the .pid file exists. Delete the pid file, then start the service should work.
check your timezone. For some reason the timezone the cronjob on my KSLE using gmt+8 instead of utc.
Thank you, it could be the culprit. But I have uninstalled & reinstalled cron, is that count ?
Yes, I have set "CRON_TZ" in the very first line of my crontab. Besides, in the testing script I have set it to every minute in crontab, so I think timezone is not an issue here.