0

I recently reinstalled my Raspberry Pi after I changed the microSD-Card. I copied all my cron jobs manually (in /var/spool/cron/crontabs/) and after I imported them with root on my new installation, they don't work anymore.

Any idea why?

This is the output of sudo ls -l /var/spool/cron/crontabs

-rw------- 1 pi   crontab 11816 Apr 19 09:24 pi
-rw------- 1 root crontab  1169 Apr 19 09:19 root

Edit:

I solved it. There were two major issues. First, I needed to set the owner-ship of my file to the Pi-User:

chown <username> /var/spool/cron/crontabs/<username>

And second, the time was wrong. Therefore the cron started an hour later than it was supposed to start.

3
  • Please run sudo ls -l /var/spool/cron/crontabs, and add the output to your question.
    – Seamus
    Apr 19, 2021 at 8:55
  • Alright, I've put the output in my question.
    – AlphaInc.
    Apr 19, 2021 at 9:18
  • It would have been better to answer your question in the answer, not in the edit. Oct 30, 2022 at 9:15

1 Answer 1

2

A simple way that keeps security ownership correct between machines is to list the details out to a file and just paste that back on the new machine using the correct user.

crontab -l > details.txt

will create the full contents (comments inc) for that users cron jobs in the file.

You can then just paste that back within an editor or pipe it back with:

cat details.txt | crontab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.