Connecting Tech Pros Worldwide Forums | Help | Site Map

How can i run the shell script using Crontab ?

Member
 
Join Date: Nov 2008
Posts: 35
#1: Jan 29 '09
Hi ,

I am want to run the shell script to run every 10 minutes of interval ,so that i have used crontab command for scheduling the shell script .. it cant works . i have checked wall command in crontab it is working properly when i try to run the shell script or even echo " name" cant to be worked using crontab.

can you please help me out for this problem?

numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,572
#2: Jan 29 '09

re: How can i run the shell script using Crontab ?


Quote:

Originally Posted by xtremebass View Post

Hi ,

I am want to run the shell script to run every 10 minutes of interval ,so that i have used crontab command for scheduling the shell script .. it cant works . i have checked wall command in crontab it is working properly when i try to run the shell script or even echo " name" cant to be worked using crontab.

can you please help me out for this problem?

Sure, we can help you, but we really need to see your crontab entry to be able to help you. Can you please post it here (enclosed in code tags) so we can see what you have tred?

Also, have you read the crontab man page? Its pretty helpful. To do that you want to use the following command:

Expand|Select|Wrap|Line Numbers
  1. man -s 5 crontab
  2.  
Member
 
Join Date: Nov 2008
Posts: 35
#3: Jan 29 '09

re: How can i run the shell script using Crontab ?


Thanks for reply.

i have attached sample file what i have used for crontab scheduling.

file -1 :(sysinfo.sh)
results of following command output is shown after crontab scheduling
<code>
echo `hostname`
echo `hostname -i`
</code>

File -2 :
Scheduling file cronfile.sh

<code>
* * * * * bash /home/project/sysinfo.sh
</code>

when i gave wall(command) " some comments" in sysinfo.sh file alone, it works, but i gave other that like echo or shell script it wont show any result in command prompt or output, i have also checked /var/log/cron file it shows the error like this
Jan 29 10:22:59 system1 CROND[6521]: (root) CMD (bash /home/project/sysinfo.sh)
Jan 29 10:22:59 system1 CROND[6521]: LAuS error - do_command.c:226 - laus_attach: (19) laus_attach: No such device



can u suggest something about this problem.
ashitpro's Avatar
Expert
 
Join Date: Aug 2007
Posts: 390
#4: Jan 29 '09

re: How can i run the shell script using Crontab ?


Quote:

Originally Posted by xtremebass View Post

Thanks for reply.

i have attached sample file what i have used for crontab scheduling.

file -1 :(sysinfo.sh)
results of following command output is shown after crontab scheduling
<code>
echo `hostname`
echo `hostname -i`
</code>

File -2 :
Scheduling file cronfile.sh

<code>
* * * * * bash /home/project/sysinfo.sh
</code>

when i gave wall(command) " some comments" in sysinfo.sh file alone, it works, but i gave other that like echo or shell script it wont show any result in command prompt or output, i have also checked /var/log/cron file it shows the error like this
Jan 29 10:22:59 system1 CROND[6521]: (root) CMD (bash /home/project/sysinfo.sh)
Jan 29 10:22:59 system1 CROND[6521]: LAuS error - do_command.c:226 - laus_attach: (19) laus_attach: No such device



can u suggest something about this problem.

when you use echo, I suggest to redirect the output to some file...
echo "hi" &> /home/ash/a.txt
see what it gives inside a.txt...

The reason is cron runs in backgroud...I think it is not attached with any tty console...Or may be puts stdout in some other file..
For safe side we always redirect output of scripts to our files..

PS: Don't forget to restart cron service....

Regards,
Ash
Reply