Operating System - HP-UX
1820390 Members
3954 Online
109623 Solutions
New Discussion юеВ

crontab output redirection

 
Christine Roberts
Occasional Contributor

crontab output redirection

I have unsuccessfully tried to redirect output from a "tar" backup job in my crontab to a file using the following in my root crontab:

0 2 * * * tar cv "files" > /tmp/logfile

Output always goes to the root mail account.

I have also found that I cannot redirect any output from the "tar" command.

HP-UX 10.20

Please advise.
And Loving It
3 REPLIES 3
John_Hancock
Trusted Contributor

Re: crontab output redirection

You also need to redirect the error out. Using the example you gave only the standard out would go to the logfile and any error messages would go to your mail.

Use the following syntax;

0 2 * * * tar cv "files" > /tmp/logfile 2>&1

This means also send error out (2) to standard out (1).

John
Blessing K Sagonda
Occasional Contributor

Re: crontab output redirection

use the standard error redirect in your crontab.
i.e crontab command 2> /tmp/out
or crontab command 2>> /tmp/out if you want to append to the file.
Christine Roberts
Occasional Contributor

Re: crontab output redirection

Pardon the pun but 'tar'.

I had tried using stderr redirection though
I had been placing it as follows

tar cv 2>&1 > /tmp/logfile

ie: the cart before the horse.

Thanks
And Loving It