Register
It is currently Sat Oct 25, 2014 3:10 pm

Issues while executing shell scripts through Cron job


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Jul 08, 2008 7:56 am   

Joined: Sat Mar 22, 2008 11:51 pm
Posts: 5
Location: Nagpur, Maharasthra, India
First Script: one.sh
cat /data/backup/scripting/shell-scripts/cron-script/one.sh

#!/bin/sh
var=three
sh /data/backup/scripting/shell-scripts/cron-script/two.sh $var

Second Script: two.sh
cat /data/backup/scripting/shell-scripts/cron-script/two.sh

#!/bin/sh
echo $1
touch $1.sh

When I manually run "one.sh" it successfully executes also executing "two.sh" but when I execute "one.sh" using cronjob it doesn't executes.

#cronjob -l
* * * * * /data/backup/scripting/shell-scripts/cron-script/one.sh

Whats going wrong here ?


Top
 Profile WWW YIM  
 PostPosted: Wed Jul 09, 2008 9:45 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Normally when a cronjob echos to STDOUT an email is generated to the user containing the output.

Try adding some echos to each script to output to a log file so you can see for sure what is called...

Code:
echo "got as far as here" >> /path/to/mylogfile


I note that when you touch the file in two.sh you have not specified a full path so the file would have been created in the cwd which normally would be the users home dir.

maybe the above can get some more info so we can work out what's happening :)


Top
 Profile  
 PostPosted: Tue Nov 18, 2008 10:16 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Usually these kind of errors show up because cron doesn't execute paths properly.
Try using full paths to the commands you want to execute :)

Best regards
Fredrik Erisson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP