How do I run Java programs from a crontab entry?

Nathan Meyers

Processes run by crontab are owned by the user who created the crontab entry, but they don't inherit the user's login environment - including the PATH environment variable. So they don't usually know where to find the java executable.

Here are a couple of ways to solve this:

  • Give the full path to the java executable in the crontab entry.

  • Have the crontab entry run a script that sets up the environment you need and then runs the command.