Home  >  Q&A  >  body text

Percent sign % doesn't work in crontab

<p>I'm having a cron problem with <code>curl</code>:</p> <pre class="brush:php;toolbar:false;">curl -w "%{time_total}\n" -o /dev/null -s http://myurl.com >> ~/log< ;/pre> <p> Works great and adds a line with total_time in the log file. </p> <p>But the same line as cron does nothing. </p> <p>This is not a path issue, since <code>curl http://myurl.com >> ~/log</code> works. </p>
P粉818088880P粉818088880444 days ago532

reply all(1)I'll reply

  • P粉340264283

    P粉3402642832023-08-25 10:13:48

    % is a special character for crontab. From man 5 crontab:

    So you need to escape the % characters:

    curl -w "%{time_total}\n" -o /dev/null -s http://myurl.com >> ~/log

    to

    curl -w "\%{time_total}\n" -o /dev/null -s http://myurl.com >> ~/log
             ^

    reply
    0
  • Cancelreply