Ive written a simple script which tests if the squid3 is running and if it isnt running start the service (so the file it recreated).
So I've written the script as:-
echo "Running test on Squid file"
if [ ! -f /var/log/squid3/access.log ]; then
echo " No Log file found"
sendemail -t email@example.com -m "Missing Squid Log" -f "firstname.lastname@example.org"
service squid3 restart
And saved it to '/home/tcross/testLog.scri
pt', and then to run it Ive added it to crontab, so:-
sudo crontab -e
* * * * * /home/tcross/testLog.script
The script works great for sending me the email, but doesnt restart the service, however if I manually run the script, the service is restarted fine by using:-
I was advised to try and grep to see what the issue is:-
ps -ef | grep testLog.script
tcross 31726 31523 0 14:38 pts/0 00:00:00 grep --color=auto testLog.scrip
Which apparently tells me that its running under tcross (me).
Any ideas how I can run the crontab as sudo?
Thank you in advance