0

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
Aaron Copley
  • 12,954
chris
  • 11

1 Answers1

1

Solution:

Instead of running 'service httpd status' run '/etc/init.d/httpd status

This has worked flawlessly. What keyed me onto this was attempting to run this in Ubuntu 14.04.2 LTS, I looked at the cron log for errors, found the errors online and substituted the above.

chris
  • 11