Agnus Dei (jackal) wrote,
Agnus Dei
jackal

calling /bin/date from cron

When making a cron that calls the date command and does math off the date command, you have to escape the %'s else cron will bomb.

In this example, I'm getting the date in milliseconds from EPOC time. Then I'm subtracting 1 hour in milliseconds (3600000) from it. So everything after 1 hour ago. I passed that on to my script (which I've removed from this example to keep it simple):

5 * * * * root AFTERTIME=`expr \`/bin/date +\%s\%3N\` - 3600000` ; echo "AFTER $AFTERTIME" >> /var/log/example_retry.log 
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments