CRON and the environment

T

Test Engineer

Guest
I'm fairly new to Linux and can't figure out why my perl backup script runs at the command line but not when using CRON. Here are the specifics:
CentOS 6.5 minimal using /bin/bash, perl script resides in /usr/bin/backup.pl, cron file I'm testing is 10 * * * * /usr/bin/backup.pl, permissions on perl script set to 750, cron log file shows execution, mailto shows execution but the backup files never show up. If I run the perl script (logged in as root), it will execute if I'm in the /usr/bin/ directory and it does create the backup files. Additional info provided as you ask. Thanks!
 


I'm fairly new to Linux and can't figure out why my perl backup script runs at the command line but not when using CRON. Here are the specifics:
CentOS 6.5 minimal using /bin/bash, perl script resides in /usr/bin/backup.pl, cron file I'm testing is 10 * * * * /usr/bin/backup.pl, permissions on perl script set to 750, cron log file shows execution, mailto shows execution but the backup files never show up. If I run the perl script (logged in as root), it will execute if I'm in the /usr/bin/ directory and it does create the backup files. Additional info provided as you ask. Thanks!
Did you do the following:

Login or su to root.

Then:

# crontab -e

And setup the command there? If not, how did you set it up?
 
Did you do the following:

Login or su to root.

Then:

# crontab -e

And setup the command there? If not, how did you set it up?

Yes, that is how I set up the cron, using crontab -e. I got the system messages "installing new crontab", and can also confirm with crontab -l that the job exists. Thanks
 
Yes, that is how I set up the cron, using crontab -e. I got the system messages "installing new crontab", and can also confirm with crontab -l that the job exists. Thanks
But, did you do it as root, or as the regular user?
 
But, did you do it as root, or as the regular user?

Sorry, yes. I created the cron as root, and the perl script belongs to root but with 750 permissions to allow others to execute. But there are no other users :)
 
Since the cron log file and mailto shows execution then the last suspect would be the destination path.

Are you using a full qualified path ?
 
I did a crontab -r and rebuilt the cron job. It seems to be working now. I'll post more if I find other issues.

Thanks for your time and assistance.
 
I was just going to inform you that I setup that script to run at 10AM this morning and it worked.

The crontab entry is 00 10 * * * /usr/bin/backup.pl

I'm glad to hear you got it straightened-out because what I know about perl you can fit on the head of a pin.

Good luck ;)
 

Members online


Latest posts

Top