Train Heartnet
Train Heartnet

Reputation: 815

How do I redirect the output and errors from a cronjob to separate files?

I have a cronjob set every 3 minutes to run a bash script. Now, I wish to separate the output and the errors to two separate files. I did read the answer given in this AskUbuntu question and tried */3 * * * * ./script.sh>>output.log 2>>errors.log (>>, since I'm creating the file in case it doesn't exist), but this seems to redirect the output again to errors.log. What am I doing wrong?

Upvotes: 1

Views: 798

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246578

That should work just fine.

Perhaps your problem is that you are not using absolute paths for the script and the log files?

Upvotes: 2

Related Questions