gumpi
gumpi

Reputation: 281

Cron job: problem with crontab, it automatically sending me an email

How can I disable the email on the cron?

Upvotes: 0

Views: 665

Answers (2)

Ariejan
Ariejan

Reputation: 11069

You can redirect the output to /dev/null like this:

* * * * * my_command > /dev/null

If an error occurs, you'll still get an email, though.

Upvotes: 1

Alnitak
Alnitak

Reputation: 339836

Send the standard output (and standard error) of your cron job to /dev/null

* * * * *  /some/cron/job 1> /dev/null 2>&1

If you'd prefer a log file, change /dev/null to a real filename instead, but be aware of the security issues. Specifically, if you're running with any sort of privileged account and the log file doesn't already exist, a hacker can pre-create a symlink in place of your log file, pointing at some other file. When your cron job runs the target of the symlink gets overwritten.

Upvotes: 2

Related Questions