Question

Ubuntu cronjobs won't run

Hello,

I’m trying to create backup cronjobs. When I run the same command in the console, its working. But when the cronjobs will be executed in crontab nothing happens.

Manually line:

/bin/tar -czf /var/backup_websites/weekly/all_websites.tar.gz /var/www

Cronjob line:

14 11 * * * /bin/tar -czf /var/backup_websites/weekly/all_websites.tar.gz /var/www

I did already change the timezone, this can’t be the problem. I think it is a problem with my permissions, but I did set permissions on 777 for the backup folders (backup_websites and weekly).

Screenshot crontab

I hope someone can help me with this problem, thanks in advance.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @dionjakobs,

I’ve tested command you provided and I can say it’s working flawless. The only thing what I can’t see is what crontab are you executing.

Please note, if you have non-root user (e.g. if you followed Initial Server Setup) there is difference between

  1. crontab -e

and

  1. sudo crontab -e

The first one (crontab -e) is creating crontab for your current user. The second one (sudo crontab -e) is creating crontab for root user. With root user, you should not have any problem as it have full permissions on every file/folder. If you have only root user, it should be working as on root, both sudo crontab -e and crontab -e opens same file. But if user is not root, it is not the case.

My you should try some debugging by writing to files, but I for me &>> or any combination of that was not working so I’m not including it. Just to note * * * * * will make your command execute every minute, so it is good for debugging.

Good luck with it mate :)