Hi guys, i am running ISPCcnfig 3 and Ubuntu 18.04 I have a problem with a cronjob it will not run, maybe you can have a look on it why the cronjob does not work moreover there is no backuplog.txt so i can see what was going wrong. When i start the script with shell it works perfectly Code: 3 1 * * * root /root/backup.sh 2>&1 /var/log/backuplog.txt thanks a lot for your kind help
Where is that crontab line? I mean, in which crontab file? Is that line the complete contents of that file?
thanks for your answer. the file is /etc/crontab the complete content is: Code: root@server4:~# cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # # backup script running every day 3 1 * * * root /root/backup.sh 2>&1 /var/log/backuplog.txt root@server4:~# the backup.sh is in /root/ directory. when i start the file sh backup.sh its running well but the cron does not work so i thought there is a fault in my cron and i wonder why an error not is written into the backuplog.txt . Must the fil backuplog.txt exist or will it be created when the script is running? thanks for your kind help
You have forgotten the output redirection to that logfile. Code: /root/backup.sh 2>&1 > /var/log/backuplog.txt Sorry I did not realise this yesterday, I was looking for a complicated error. Testing cron is easier by setting MAILTO and running without redirections, then you get the full output emailed to you.