I was trying to learn about crontab. I tried to execute shell script using crontab. But I did not get the expected result.
When I use crontab,

38 17 * * * bin/sh sh /home/agalya/unix/digiclock.sh

I can't execute the shell script.

when I use 'at' command also I did not get the output.I have a doubt whether I have given the path of shell script correctly.How should I give the path?

~$ at 17:25
warning: commands will be executed using /bin/sh
at> /bin/sh sh /unix/digiclock.sh
at> <EOT>
job 9 at Sat Feb 20 17:25:00 2016

I am sure that the file has executable permission.

  • In your crontab entry, bin/sh sh doesn't make any sense. Either use /bin/sh (note leading slash) or just sh (if it's in the standard PATH), not both. – Kusalananda Feb 20 '16 at 12:23
  • 2
    In fact, if the script itself is executable and contains a #!-line at the top, neither of /bin/sh and sh should be needed. – Kusalananda Feb 20 '16 at 12:25

Your crontab entry contains stuff that must be removed. It should be

38 17 * * *  /home/agalya/unix/digiclock.sh

for an user crontab. If it's in /etc/crontab (system-wide crontab), then it must include the user that runs the command:

38 17 * * *  agalya  /home/agalya/unix/digiclock.sh
  • I have tried the above command but the shell script is not executing on the given time,Do I need to make any other changes?? – Silviya Feb 22 '16 at 23:02
  • 1) Have you tried to run the script to see if it works? 2) Check /etc/cron.allowand /etc/cron.deny to ensure that user agalya is allowed to use crontab. – dr01 Feb 23 '16 at 8:13
  • I can run the script in command prompt.If I use write command in crontab it is working.How can I check whether agalya is allowed to use crontab.kindly give me a detailed explanation on how to check whether I am allowed to use crontab – Silviya Feb 28 '16 at 7:37
  • man crontab will give you all the information you need. – dr01 Feb 28 '16 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.