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

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...