LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   send all output to file, gzip in crontab (https://www.linuxquestions.org/questions/linux-newbie-8/send-all-output-to-file-gzip-in-crontab-4175424156/)

figure20012 08-27-2012 02:16 AM

send all output to file, gzip in crontab
 
13 11 * * * /home/devin/Desktop/bla.sh &> /home/devin/Desktop/bla.log | exec /bin/gzip ;
can someone tell me why it dows not work
please help

evo2 08-27-2012 02:23 AM

Hi,

that looks like it wouldn't even work on the command line. How about the following:
Code:

/home/devin/Desktop/bla.sh 2>&1 | /bin/gzip - > /home/devin/Desktop/bla.log.gz
Evo2.

evo2 08-27-2012 02:29 AM

Oops, you actually explicitly asked why it wouldn't work. Hmm..

Firstly you have "&>" which will background the process and send the stdout to the file /home/devin/Desktop/bla.log (Perhaps you wanted ">&" or "2>&1" which will send stderr to stdout). Next you have a pipe, "|" to "exec /bin/gzip"... there a number of issues here. Why the "exec"? And gzip will only take stdin as input if given "-" as the input file etc, and you've already redirected the output of your script to bla.log.

HTH,

Evo2.

figure20012 08-27-2012 02:59 AM

Quote:

Originally Posted by evo2 (Post 4765120)
Hi,

that looks like it wouldn't even work on the command line. How about the following:
Code:

/home/devin/Desktop/bla.sh 2>&1 | /bin/gzip - > /home/devin/Desktop/bla.log.gz
Evo2.

thanks a lot for helping evo2 :)

figure20012 08-27-2012 03:54 AM

Quote:

Originally Posted by evo2 (Post 4765120)
Hi,

that looks like it wouldn't even work on the command line. How about the following:
Code:

/home/devin/Desktop/bla.sh 2>&1 | /bin/gzip - > /home/devin/Desktop/bla.log.gz
Evo2.

can i mail the gzip file to my account?

pan64 08-27-2012 04:26 AM

yes, you can but it depends on the size of that file. See the man page of mailx: http://linux.die.net/man/1/mailx, you can try something like this:
echo "this is the log file of ... at ...." | mailx -s <subject> -a <attachment> <your address>


All times are GMT -5. The time now is 04:07 AM.