Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4605750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:28:25+00:00 2026-05-22T00:28:25+00:00

I have one cron job where I want to send its output to /dev/null

  • 0

I have one cron job where I want to send its output to /dev/null but in case an error happens then it should send an email.

Otherwise I get an email daily of the output of cron and it’s difficult for me to see when errors occured or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:28:25+00:00Added an answer on May 22, 2026 at 12:28 am

    How about

    59 23 * * * { tmpFile=/tmp/yourCmdErrs.$$ ; export tmpFile ; yourCommand > /dev/null 2>${tmpFile}; if [ -s ${tmpFile} ] ; then mailx -s"errors in yourCommand" < ${tmpFile} ; /bin/rm ${tmpFile} ; fi ; }
    

    Exploded, it is

    # set whatevery your time/days are # 59 23 * * * 
    # my superstition to use open and closing # { }
    # set a tmpFile var # tmpFile=/tmp/yourCmdErrs.$$ ; export tmpFile ;
    # run yourCmd save STDERR to file # yourCommand > /dev/null 2>${tmpFile}; 
    # check if tmpFile has anything in it # if [ -s ${tmpFile} ] ; then 
    # obvious, hopefully # mailx -s"errors in yourCommand" < ${tmpFile} 
    #  cleanup tmpFile # /bin/rm ${tmpFile} ;
    #  fi 
    # note that closing ';' is a must when using {} pairs ; }
    

    The actual call to mail/mailx may be slightly funky, I don’t have a way to test it right now.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to delete one record every 5 seconds and have a cron job
I have cron job - php script which is called one time in 5
I have first time installed th cron job for magento. THere is one module
I have one XML request which I need to modify (to XML) and then
I have one database whose size is growing very fast. Curruntly its size is
I have couple of php scripts which are called by cron. The cron job
I have a cron job that updates a large number of rows in a
I'm trying to write a cron job that checks and then does some transformations
I have checked for a solution here but cannot seem to find one. I
I am using Ubuntu server, and I want to do a wget cron job

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.