0

a.sh contains:

mkdir abc

I made it executable using:

chmod 777 a.sh

Then I configured crontab using:

crontab -e

And entered this line:

56 09 * * * /home/subir/Jarvis/a.sh

The abc directory is not created at that given time.

Which steps can I take to figure out why this does not work as expected?

5
  • 1
    What happens if you run /home/subir/Jarvis/a.sh from an interactive shell? – Haxiel Dec 7 '19 at 5:42
  • This is exactly the same as in Crontab to make directory in Desktop – Freddy Dec 7 '19 at 10:09
  • Put all permission stills not running – Subir Makur Dec 7 '19 at 17:12
  • You've got the abc directory in your home directory though, is that not where you want it? If so create it elsewhere. – Kusalananda Dec 7 '19 at 17:20
  • 1
    Does anything in cron work? Maybe you aren’t in the cron.allow file. – bxm Dec 7 '19 at 20:01
0

If that’s exactly how you created the file, you haven’t set execute permission on it. You missed out this:

chmod +x a.sh

You may wish to set a more specific mode, refer to man chmod for more details.

If you don’t want to make it executable for some reason, you can still run in cron it by invoking it with your shell interpreter, e.g.

/bin/bash /home/subir/Jarvis/a.sh

Amend to use you preferred shell.

4
  • If they used chmod 777 on the file, it's most certainly executable. That is not the issue. – Kusalananda Dec 7 '19 at 17:21
  • Agreed, though that info was not available when I answered. – bxm Dec 7 '19 at 19:53
  • Now I don’t know what to think ¯\_(ツ)_/¯ – bxm Dec 7 '19 at 23:17
  • As in "Crontab to make directory in Desktop", I suspect that the script is run, but that it creates the directory in a place where they don't expect it to be created (their home directory). The location of the script itself does not magically become the current working directory of the script. As to why they accepted your answer, your guess is as good as mine. – Kusalananda Dec 7 '19 at 23:24

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.