5

I have a crontab script which runs fine from the interactive shell. However when running from crontab it fails because it doesnt run the scripts in /etc/profile.d/ (e.g. /etc/profile.d/java.sh)

Whats the best way of fixing this?

DD.
  • 3,254

2 Answers2

7

begin the shell script with:

#!/bin/bash -l

This causes bash to start as a login shell, which means it will read /etc/profile and ~/.bash_profile.

DD.
  • 3,254
3

Set SHELL on your crontab:

SHELL=/bin/bash
* * * * * # your_job