Debug cron job - how to get results emailed?

6,481

Just remove the ">/dev/null 2>&1", and anything the command outputs will be emailed.

Cron normally emails the output of commands, if the commands output anything, unless you include redirection operators, which is exactly what "2>&1" and ">/dev/null" are.

Share:
6,481

Related videos on Youtube

Strategerizer
Author by

Strategerizer

Updated on September 17, 2022

Comments

  • Strategerizer
    Strategerizer over 1 year

    I am trying to debug why my the support ticket system I am setting up is not pulling the POP email from my Google Apps email.

    I set up a cron job for this, per the instructions of the developer of the support ticket system:

    php -q /home/username/public_html/support_ticket_sw/pipe/pop.php >/dev/null 2>&1
    

    Then, based on some other thread on this site, I did this...

    php -q /home/username/public_html/support_ticket_sw/pipe/pop.php >/dev/null 2>&1 | mail -s "cron output" [email protected]
    

    ...Now I get emails but they are empty. Do I need to put something relevant in stead of "cron output". I assumed that is the email subject line but maybe thre should go the output of the cron job? I don't know what that is...

  • Strategerizer
    Strategerizer over 13 years
    Thanks, that clarified that aspect. I am now getting the error message: Error Occurred: Can't connect to gmail-pop.l.google.com,995: Connection timed out.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 13 years
    And if you want the mails sent to some external address rather than your local mailbox, put [email protected] at the beginning of the crontab.
  • Tony Maro
    Tony Maro over 11 years
    Actually Gilles is incorrect - the line should read: [email protected]