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

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

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!


Try this:

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

  • 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. Aug 27 '12 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.