LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-07-2015, 07:12 AM   #1
circus78
Member
 
Registered: Dec 2011
Posts: 273

Rep: Reputation: Disabled
crontab and stdout


Hi,
I am using Debian 6 and I have this cronjob:

Code:
8 0 * * * /bin/tar -czf /var/spool/backup/home-`date +\%Y\%m\%d`.tar.gz -T /root/folder.txt 1>/dev/null
/root/folder.txt contains:

Code:
/home/user1
/home/user3
/home/user44
..

Every day I get this by email:

/bin/tar: Removing leading `/' from member names

Why? I think this is stdout, and I put 1> /dev/null in my script.

Thank you
 
Old 03-07-2015, 08:24 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
That message is being sent to stderr. Either of these will work:
Code:
8 0 * * * /bin/tar -czf ... >/dev/null 2>&1
8 0 * * * /bin/tar -czf ... &>/dev/null
Of course that will discard all error messages. It would be better just to avoid the error by running tar from the root directory and removing the leading "/" from the paths in that file.
Code:
8 0 * * * /bin/tar -czf /var/spool/backup/home-`date +\Y\%m\%d`.tar.gz -C / -T /root/folder.txt 1>/dev/null
or
Code:
8 0 * * * cd / && /bin/tar -czf /var/spool/backup/home-`date +\%Y\%m\%d`.tar.gz -T /root/folder.txt 1>/dev/null

Last edited by rknichols; 03-07-2015 at 08:33 AM. Reason: Add "better to avoid ..."
 
Old 03-07-2015, 12:16 PM   #3
circus78
Member
 
Registered: Dec 2011
Posts: 273

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
That message is being sent to stderr. Either of these will work:
Code:
8 0 * * * /bin/tar -czf ... >/dev/null 2>&1
8 0 * * * /bin/tar -czf ... &>/dev/null
Of course that will discard all error messages. It would be better just to avoid the error by running tar from the root directory and removing the leading "/" from the paths in that file.
Code:
8 0 * * * /bin/tar -czf /var/spool/backup/home-`date +\Y\%m\%d`.tar.gz -C / -T /root/folder.txt 1>/dev/null
or
Code:
8 0 * * * cd / && /bin/tar -czf /var/spool/backup/home-`date +\%Y\%m\%d`.tar.gz -T /root/folder.txt 1>/dev/null
Hi,
I get the same behavior:

Code:
/home/user:# tar -czf /var/spool/backup/backup.tar.gz -C / -T /root/folder.txt
tar: Removing leading `/' from member names
Code:
/home/user:# cd /
/# tar -czf /var/spool/backup/backup.tar.gzz -T /root/folder.txt
tar: Removing leading `/' from member names

Thank you for your answer (I was wrong about stdout...)
 
Old 03-07-2015, 12:39 PM   #4
circus78
Member
 
Registered: Dec 2011
Posts: 273

Original Poster
Rep: Reputation: Disabled
Sorry, of course I need to strip "/" from my folder.txt

Thank you
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar - write to stdout & create log files ( from stdout and stderr ) [solved] paziulek Linux - General 2 02-23-2014 12:26 PM
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
How to redirect standard stdout to multi stdout ( Bash )? john.daker Programming 4 11-03-2008 11:20 PM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration