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
#check httpd status and output to file service httpd status >> /var/log/messages;
#check pptpd status and append to file netstat -punta | grep cupsd >> /var/log/messages;
exit
– chris Jun 10 '15 at 01:34tcp6 0 0 ::1:631 :::* LISTEN 1975/cupsd – chris Jun 10 '15 at 01:45
tcp6 0 0 ::1:631 :::* LISTEN 1975/cupsd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1975/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 1975/cup – chris Jun 10 '15 at 01:51
/var/log/messagesis a syslog file; you should not be overwriting this with anything. – Michael Hampton Jun 10 '15 at 02:45