LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cron job no function no error (https://www.linuxquestions.org/questions/linux-software-2/cron-job-no-function-no-error-602579/)

wanghao 11-26-2007 07:29 PM

cron job no function no error
 
I wrote a scrip to backup my home file which i set it to exec it every five minutes ,
that the crontab is :
*/5 * * * * job #(i 've tested it before add to crontab ,it works fine ) >>/home/myhome/error.log

but as i list the backup file there's nothing ,and found check the error.log ether.
i'm not sure what had happened so i seek for the deamon "crond",it's working ,
the second is the /etc/cron.deny and /etc/cron.allow,both file not exist .So i don't why
not my cron job not works ,who knows be help me thanks !

chrism01 11-26-2007 07:35 PM

cron has a minimal default environment, so you need to specify the complete (absolute) path to any cmds and/or files you use.
Please post your code for further help (in code tags).

jailbait 11-26-2007 07:36 PM

cron has a very skimpy PATH. One common cause of the type of problem that you are experiencing is that Linux can find the program when you execute it from the command line but not find it when you execute it from cron. The solution is to specify the full path name for the program that you are executing in cron. For example use:
/usr/bin/backutil
instead of:
backutil

--------------
Steve Stites

chrism01 11-26-2007 07:47 PM

glad we agree ;)

wanghao 11-26-2007 07:59 PM

Yes ,i've been considered the relevant path problem ,but all my program used the absolute path.and hereis is my crontab job :

*/5 * * * * sh /home/myhome/backup >>/home/myhome/log/error.log
and the below is the script :

#!/bin/csh
# For backup myfiles

#remove the old files

cd /home/myhome/backup
rm *
name=`sh /home/myhome/bin/get-date` #a script for the current data ,fine

#now backup the new file
tar -cvzf /home/myhome/backup/myfile${name}.tar.gz /home/myhome

#end

ok ,the the whole code except date-get script .

jailbait 11-27-2007 12:37 PM

Quote:

Originally Posted by wanghao (Post 2971680)
Yes ,i've been considered the relevant path problem ,but all my program used the absolute path.and hereis is my crontab job :

*/5 * * * * sh /home/myhome/backup >>/home/myhome/log/error.log

Try giving the complete path for sh.

-----------------
Steve Stites

chrism01 11-27-2007 06:01 PM

Actually, I'd simplify by putting the shell in the 1st line and not using sh cmd (in all instances).
Also, supply the complete path for tar, it's NOT a shell built-in.


All times are GMT -5. The time now is 05:27 PM.