I have a simple script and asking crontab to execute that script. In the script, I have 2 commands I want to run and append the output to a file. Only one of the commands does as it should. However, if I run the script myself as 'root', the script works. All the machines, RHEL, Ubuntu Server/Desktop and Fedora have the same outcome. Below is my script and crontab -l
.
I have been researching and trying everything, even setting the $PATH
, but nothing. The service httpd status
will not run.
#!/bin/bash
#check httpd status and append to file
service httpd status >> /path/to/file;
#check cupsd status and append to file
netstat -punta | grep cupsd >> /path/to/file;
exit
Crontab:
*/1 * * * * /usr/local/bin/script.sh