If I run my backup script manually from the command line it works fine. No issue backup is created. In the crontab log, I can see the entry for running the backup at 2:00 AM, /home/sgaddis/copy-production-db.sh
:
Dec 23 01:01:01 mapehr anacron[11921]: Anacron started on 2019-12-23
Dec 23 01:01:01 mapehr anacron[11921]: Normal exit (0 jobs run)
Dec 23 01:01:01 mapehr run-parts(/etc/cron.hourly)[11923]: finished 0anacron
Dec 23 02:00:01 mapehr CROND[14869]: (sgaddis) CMD (sgaddis /bin/bash /home/sgaddis/copy-production-db.sh)
Dec 23 02:01:01 mapehr CROND[14934]: (root) CMD (run-parts /etc/cron.hourly)
Dec 23 02:01:01 mapehr run-parts(/etc/cron.hourly)[14934]: starting 0anacron
Dec 23 02:01:01 mapehr anacron[14943]: Anacron started on 2019-12-23
but when I look in the /home/sgaddis/backup
there is no backup.
It should not be a permission issue since it is my home/backup folder. My account should have the right to dump the backup there as it does when I run the script manually. Any place else I should be looking for clues?
I went to https://linux4one.com/how-to-set-up-cron-job-on-centos-7/ to see if there was anything I left out in creating the cronjob
I searched this site was unable to find a question similar to this one. The cronjob is not hanging or not being executed. The closest I found was
https://stackoverflow.com/questions/44723154/using-cronjob-to-automatically-backup-mysql-files,
but as I said earlier in my post I have already run the script from the command line and it works fine so the above post does not answer my question.
does not produce a similar question to the one that I have posted. If you know of a similar post please point it out and not just vote down my post.
The exact line is this
0 2 * * * root /bin/bash /home/sgaddis/copy-production-db.sh
==UPDATE==
This is the command that is in the log file today.
mapehr CROND[21076]: (sgaddis) CMD (/bin/bash /home/sgaddis/copy-production-db.sh)
Now it is using my user account to launch the cron job.
Maybe my user account does not have permission to execute a cron job?
(sgaddis) CMD (sgaddis /bin/bash ...
suggests erroneous inclusion of a username field in the crontab entrysudo crontab -e
.