Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Try this:

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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