DD. Asked: 2012-05-30 23:44:32 +0800 CST2012-05-30 23:44:32 +0800 CST 2012-05-30 23:44:32 +0800 CST Crontab /etc/profile.d 772 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? linux cron profile 2 Answers Voted Best Answer DD. 2012-05-31T01:00:56+08:002012-05-31T01:00:56+08:00 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. Thiago Figueiro 2015-12-07T23:16:13+08:002015-12-07T23:16:13+08:00 Set SHELL on your crontab: SHELL=/bin/bash * * * * * # your_job
begin the shell script with:
This causes bash to start as a login shell, which means it will read /etc/profile and ~/.bash_profile.
Set SHELL on your crontab: