2

How can I log the output of a command executed by at?

This command is actually being exec()'d by PHP as in:

<?php
exec('echo "curl -k https://localhost/projekt/crons/purge/5" | at now + 5 minutes');

I need to capture the response from the curl request and log it to a file. The man pages state:

The user will be mailed standard error and standard output from his commands, if any. Mail will be sent using the command /usr/lib/sendmail. If at is executed from a su(1) shell, the owner of the login shell will receive the mail.

Who owns the mail (www-data?), and how can I access it? Are the docs referring to OS mail belonging to a user, or, actual email? Thanks!

1 Answers1

3

Try this:

$ echo "curl -k https://localhost/projekt/crons/purge/5 > projekt.log 2>&1" | at now + 5 minutes

quanta
  • 50,327
  • 19
  • 152
  • 213
  • Works great, thanks for putting me on the right path. I found `>>`is append whereas `>` is (over)write. Thanks. The other option, I suppose, would be to just write the log file using PHP inside the call to `https://localhost/projekt/crons/purge/5`. Cheers. – Jordan Arseno Aug 27 '12 at 17:47