I have a script abc.sh and I have scheduled it in crontab.now abc.sh is calling another script using sudo. When I am executing abc.sh manually it is working fine..but from scheduler abc.sh is running every 5 minutes but It is unable to call another script using sudo. This is strange for me..can any one help me on this please
Asked
Active
Viewed 337 times
-2
-
Does sudo has allowed passwordless execution of abc.sh child script? – myaut Sep 08 '17 at 17:05
-
Welcome to Stack Overflow, @AMITGHOSH. Please review: https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/mcve. In particular, you will want to supply some details on your scripts and cron configuration. – Degan Sep 08 '17 at 17:14
-
Yes..my child script does not require any password...manually I tested..and working as expected – AMIT GHOSH Sep 08 '17 at 17:18
-
sudo /opt/clearcache.sh...this is what abc.sh is calling – AMIT GHOSH Sep 08 '17 at 17:23
2 Answers
1
You can take a look at /var/mail/<username>
file to see if cron job is sending some error or warning message. Or maybe you have not set executable permissions for the /opt/clearcache.sh
file?

Ajay
- 156
- 8
-
I didn't find recent cron related log in above mentioned directory...even no problem with executable permissions.i have sudo access to clearcache.sh file – AMIT GHOSH Sep 09 '17 at 05:10
0
This happens often when people use sudo. The environment YOU use is not set for the privileged user. As such, your $PATH and other environment variables may not be set as you expect. You can set this up, or change the sudo behavior... however most people simply work-around this by using full paths to files in cron.
Have a look at this post as well: Where can I set environment variables that crontab will use?

t3ln3t
- 230
- 2
- 6