David11011
asked on
Ubuntu CRON doesn't run bash scripts
I've got a bash script
that is saved to /backup_ABOL.sh
I've opened my crontab file with "sudo crontab -e" and added these lines
When the CRON job runs, the cronTest.txt file is created but the file from the bash script isn't created.
When I run the script manually ". /backup_ABOL.sh" it creates the file without any problems.
These are the things I've tried in the CRONTAB file
#!/bin/bash
sudo touch /test/scriptTest.txt
that is saved to /backup_ABOL.sh
I've opened my crontab file with "sudo crontab -e" and added these lines
03 16 * * * /backup_ABOL.sh
03 16 * * * sudo touch /test/cronTest.txt
When the CRON job runs, the cronTest.txt file is created but the file from the bash script isn't created.
When I run the script manually ". /backup_ABOL.sh" it creates the file without any problems.
These are the things I've tried in the CRONTAB file
03 16 * * * /backup_ABOL.sh
03 16 * * * ./backup_ABOL.sh
03 16 * * * . /backup_ABOL.sh
03 16 * * * /bin/bash /backup_ABOL.sh
03 16 * * * /bin/bash . /backup_ABOL.sh
SHELL=/bin/bash
03 16 * * * /backup_ABOL.sh
SHELL=/bin/bash
03 16 * * * . /backup_ABOL.sh
SHELL=/bin/bash
03 16 * * * ./backup_ABOL.sh
none of them will run the script. any ideas?
ASKER
It really is at /.
I've tried copying the file to my home directory and putting the path into the CRONTAB file but it doesn't make any difference. It still doesn't run. I would rather have it at the directory root because it will be much easier to find later. I log into this server like 2x a year.
I've tried copying the file to my home directory and putting the path into the CRONTAB file but it doesn't make any difference. It still doesn't run. I would rather have it at the directory root because it will be much easier to find later. I log into this server like 2x a year.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What user is the cronjob running as?
ASKER
That was it. I changed the file permissions and now it runs like a champ. Thanks.
Does backup_ABOL.sh really exist in /
You would need root perms to place it in the root dir.
I suspect it is really in your home dir, in which case do
13 16 * * * /home/username/backup_ABOL