Cron Job - Troobleshooting
-
@Curtis said in Cron Job - Troobleshooting:
I have a script that runs a backup, and works perfectly, but for some reason it's not working via Cron. What is the best way to troubleshoot it?
Can you give a screenshot of the cron job?
-
Cron doesn’t run with your environment variables. Make sure to use full paths.
-
Pipe the cron job to a log file. Are you using Fedora ? (i noticed weird stuff in it with crontab)
-
Ubuntu 18.04
-
@JaredBusch said in Cron Job - Troobleshooting:
Cron doesn’t run with your environment variables.
I have variables in the script, that should be fine, correct?
-
Here is the Cron Job:
0 0 * * * /root/auto-backup.sh
-
@Curtis : can you show us the contents of the .sh file?
-
@Curtis said in Cron Job - Troobleshooting:
Here is the Cron Job:
0 0 * * * /root/auto-backup.sh
That's a very simple cron job, what error do you get when it runs?
-
@DustinB3403 One would think, right? No errors. Maybe there is a log somewhere?
-
@Curtis Look in the logs.
-
@DustinB3403 where?
-
@Curtis check:
tail -n 500 /var/log/cron.log or journalctl | grep CROND
-
@Curtis said in Cron Job - Troobleshooting:
@JaredBusch said in Cron Job - Troobleshooting:
Cron doesn’t run with your environment variables.
I have variables in the script, that should be fine, correct?
If they are all defined when run in an environment-less way.
-
So I just figure out that at least part of the script is running, however the rclone doesn't seem to be syncing the data to the cloud. Maybe I'll break the script into 2 parts to troubleshoot. Funny thing is when I run it manually, it works great.
-
@Curtis said in Cron Job - Troobleshooting:
So I just figure out that at least part of the script is running, however the rclone doesn't seem to be syncing the data to the cloud. Maybe I'll break the script into 2 parts to troubleshoot. Funny thing is when I run it manually, it works great.
Are you testing as root when running manually?