Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a linux machine with ntpdate installed and it is working when i run it from my ssh terminal or from a shell script manually.

However , when i add the shell script to crontab i get the error

ntpdate: command not found


LOGPATH="/home/test/" ntpdate -q $NTPSERVER>$LOGPATH/tmp.txt

if [ $RETVAL -ne 0 ] ; then
echo "Failure Unable to query NTP Server :">>$LOGPATH/ntpdebug.txt
date >>$LOGPATH/ntpdebug.txt
exit $RETVAL

echo "Local Time: ">>$LOGPATH/ntpdebug.txt date >>$LOGPATH/ntpdebug.txt cat $LOGPATH/tmp.txt>>$LOGPATH/ntpdebug.txt

ntpdate $NTPSERVER

if [ $RETVAL1 -ne 0 ] ; then
echo "Failure Unable to connect NTP Server :">>$LOGPATH/ntpdebug.txt
date >>$LOGPATH/ntpdebug.txt
exit $RETVAL1

echo "Synchronized" >>$LOGPATH/ntpdebug.txt

share|improve this question
up vote 2 down vote accepted

Use full path!

/usr/sbin/ntpdate $NTPSERVER

cron doesn't include any ~/.bashrc, ~/.zshrc, etc., so the $PATH maybe unset.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .