0

I need to set up a cron job that runs every 15 minutes between 8am and 8pm. After googling, I decided to use it this way:

*/15 8-20 * * * /path/of/shellscript.sh

However, the cron is not getting triggered. What should be the right expression?

Edits:

*/15 8-19 * * * /path/of/shellscript.sh
00 20 * * * /path/of/shellscript.sh

The cron executes. However the logs show this error:

Mailed 62 bytes of output but got status 0*0047

However, if I run the run the script manually, it executes fine!

G3V
  • 111
  • 1
  • 9
  • That should run every 15 minutes from 08:00 to 20:45, which isn't *quite* what you said you wanted. How do you know it's not executing? Does `shellscript.sh` depend on an environment variable? What if you replace `/path/of/shellscript.sh` by, say, `date >> $HOME/cronlog`? – Keith Thompson Nov 05 '15 at 04:46
  • The shell script runs a jar file to download an excel sheet and store it at a location. I could not find the excel downloaded at the location. If I execute the script manually, I can fins the excel downloaded at the proper location. No, it doesn't depend on an environment variable – G3V Nov 05 '15 at 04:50
  • Remember that the environment variables you have when you run script manually is not the same as the environment variables cron will have. You can set up variables in your cron like this: http://stackoverflow.com/questions/3639415/variables-in-crontab. Also your cron entry should look like `0,15,30,45 8-20 * * * /path/of/shellscript.sh` – zedfoxus Nov 05 '15 at 04:52
  • For the most common cron implementation (Vixie cron), `*/15` is equivalent to `0,15,30,45`. – Keith Thompson Nov 05 '15 at 06:03

1 Answers1

0

Resolved by setting permissions to the sh file and the jar file

chmod 0777 shellscript.sh
chmod 0664 jarfile.jar
G3V
  • 111
  • 1
  • 9
  • 1
    Setting the permissions to `777` means that the script is writable by anyone on the system. That might not matter if you're the only user, but it's still a bad habit to be overly permissive. `755` is better, or `775` if you need group write access (you probably don't). (BTW, the `chmod` command assumes octal; the leading `0` is not needed.) – Keith Thompson Nov 05 '15 at 18:29