Wednesday, May 27, 2015

linux - Crontab /etc/profile.d



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?


Answer



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.


No comments:

Post a Comment