LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-26-2007, 07:29 PM   #1
wanghao
Member
 
Registered: Mar 2007
Distribution: centos
Posts: 126

Rep: Reputation: 15
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 !
 
Old 11-26-2007, 07:35 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
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).
 
Old 11-26-2007, 07:36 PM   #3
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,527

Rep: Reputation: 177Reputation: 177
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
 
Old 11-26-2007, 07:47 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
glad we agree
 
Old 11-26-2007, 07:59 PM   #5
wanghao
Member
 
Registered: Mar 2007
Distribution: centos
Posts: 126

Original Poster
Rep: Reputation: 15
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 .
 
Old 11-27-2007, 12:37 PM   #6
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,527

Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by wanghao View Post
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
 
Old 11-27-2007, 06:01 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron error: no job control schentor Linux - Software 2 07-18-2005 12:39 PM
need help with cron job parthcorp1 Linux - General 2 02-01-2005 11:37 AM
"permission denied" error when cron job executes jillu Linux - Newbie 11 11-02-2004 01:19 PM
cron job <defunct> error? existo Slackware 7 01-21-2004 03:39 PM


All times are GMT -5. The time now is 11:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration