LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-04-2024, 02:00 AM   #1
dchmelik
Senior Member
 
Registered: Nov 2008
Location: USA
Distribution: Slackware, FreeBSD, Illumos, NetBSD, DragonflyBSD, Plan9, Inferno, OpenBSD, FreeDOS, HURD
Posts: 1,074

Rep: Reputation: 149Reputation: 149
Question still get mail from cron job redirected to /dev/null?


I still get mail from this cron job. Is it because it's several commands and every one needs redirection, so maybe they're better done as a script?

Code:
MAILTO=""
0 7 * * * cd /usr/local/lib64 && tar cJvf eggdrop.tar.xz eggdrop && chown user:users eggdrop.tar.xz && mv eggdrop.tar.xz /home/user 1> /dev/null 2>&1

Last edited by dchmelik; 02-04-2024 at 02:02 AM.
 
Old 02-04-2024, 02:48 AM   #2
Thom1b
Member
 
Registered: Mar 2010
Location: France
Distribution: Slackware
Posts: 486

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
Hi,
You can create a script, or you can redirect every command. In your case, the tar command needs to be quiet with 1>/dev/null.
 
1 members found this post helpful.
Old 02-04-2024, 04:49 AM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
If you're throwing the output away there's really no point on having that -v on the tar.

You could format it as { cmd1 && cmd2 && cmd3 ; } >/dev/null 2>&1

Note: that final semi-colon is not optional when using { }.


That said, when it comes to cron, my outlook has been to always put anything more complex than a single command into a script file.
 
2 members found this post helpful.
Old 02-04-2024, 06:53 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,982

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
just some comments:
if you suppress all the output you will never know what's happened, if there was any error or if it was executed at all.
As it was mentioned probably would be better to put it into a script.
Add some error handling and logging, write the report into a file - if you don't want to send mail.
 
  


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
[SOLVED] Stopping cron job emails to root, do I use >/dev/null 2>&1 or &> /dev/null anon091 Linux - Newbie 3 11-12-2013 10:21 AM
Some of the output redirected to /dev/null appears on the screen while 'scripting' gregorian Linux - Newbie 27 06-23-2008 09:44 AM
What is meant by " file > /dev/null 2>&1 </dev/null " attockonian Linux - Newbie 5 06-30-2006 10:51 PM
1> /dev/null 2> /dev/null elyk Programming 9 09-20-2004 05:44 PM
1>/dev/null 2>/dev/null chr15t0 Linux - General 2 07-19-2002 08:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:40 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