Score:0

Crontab won't run bash cript

tz flag

I have a bash script that takes backup of my gitlab server and copies the files to another disk.

The script runs as expected when I run it by hand.

I tried to add it as a job in crontab but it doesn't seem to run.

This is how I tried to setup the crontab:

sudo crontab -e

I set it up to run every day at 12:00.
I tried different times as well, but still no luck.
0 12 * * * root /home/user/dev/backup.sh

sudo /etc/init.d/cron restart

However I do not see any files in the expected directory. If I manually run the script it works fine.

The first line of my script contains #!/bin/bash I don't know if that matters.

Score:2
br flag

If you use sudo crontab -e it is always the crontab of root and there it is a syntax error to add the username. Make sure the script has the executable bit set (chmod +x /home/user/dev/backup.sh).

This crontab entry should do it:

0 12 * * * /home/user/dev/backup.sh
MrCookie avatar
tz flag
I was about to answer my own question but, yes that's how it works. Thank you very much!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.