How can i run the shell script using Crontab ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xtremebass
    New Member
    • Nov 2008
    • 38

    How can i run the shell script using Crontab ?

    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
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by xtremebass
    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:

    Code:
    man -s 5 crontab

    Comment

    • xtremebass
      New Member
      • Nov 2008
      • 38

      #3
      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:22 6 - laus_attach: (19) laus_attach: No such device



      can u suggest something about this problem.

      Comment

      • ashitpro
        Recognized Expert Contributor
        • Aug 2007
        • 542

        #4
        Originally posted by xtremebass
        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:22 6 - 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

        Comment

        Working...