A suggestion: if the first line is testing the number of processes matching 'httpd' you could simplify it to
Code:
APPCHK=$( pgrep httpd | wc -l )
As to why you are getting different behaviour when run in cron, two possibilities:
- You might be running under a different shell. You could fix it by adding
as the first line.
- There might be different environment variables set.
I would add some tracing (to a file) to make sure that the intermediate commands in the first line are returning what you expect.