Recently while trying to auto-restart a daemon which is down by identifying with ps aux and if condition, it is not worked as intended with crontab.
I used following command which is perfectly running in from command line but not through crontab.
if [ `ps aux | grep nrpe | grep -v grep | wc -l` -eq 0 ]; then service nagios-nrpe-server restart ;fi
After trying with different commands following thing worked for me:
pgrep nrpe; [ $? != 0 ] && /etc/init.d/nagios-nrpe-server restart
where pgrep returns non zero exit code if the process nrep is not running and with $? is used to get the exit code of previous command (in this case pgrep) and start the process.