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.

Is there a simple way to determine whether a shell script was initiated via cron or manually by the user? In my case, I want the script to send output to a log file when run via cron, but to stdout when initiated manually.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

What about simply setting up the command in the crontrab to redirect stdout to a file (>> for append)?

Something like:

XX XX XX XX XX /path/to/cmd >> outputfile.log

share|improve this answer
    
My, that was simple. Thanks. –  eykanal May 9 '11 at 20:18
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.