How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Stop Cron Output (and the Spam Emails)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Server Management > How to Stop Cron Output (and the Spam Emails)
Server Management

How to Stop Cron Output (and the Spam Emails)

how7o
By how7o
Last updated: May 23, 2026
5 Min Read
Stop cron job output and the resulting email spam
SHARE

To stop cron output (and the email cron sends whenever a job produces output), redirect both stdout and stderr to /dev/null by appending >/dev/null 2>&1 to the command. For a job that fetches a URL like http://example.com/cron.php, the silent version is:

Contents
  • What the redirection does
  • Keep error emails only
  • Log to a file instead
  • For local PHP scripts
  • wget‘s own quiet flag
  • Frequently asked questions
  • Related guides
  • References
* * * * * wget http://www.example.com/cron.php >/dev/null 2>&1

Last verified: 2026-05-17 on Ubuntu 22.04 and AlmaLinux 9. Originally published 2023-11-30, rewritten and updated 2026-05-17.

What the redirection does

  • >/dev/null — sends stdout (file descriptor 1) to the system’s “throw it away” device.
  • 2>&1 — sends stderr (file descriptor 2) to the same place stdout is going. Order matters: this has to come after the stdout redirect.

Cron emails the user when a job writes anything to stdout or stderr. Sending both to /dev/null silences both channels, so no email and no log.

Stop cron output — >/dev/null 2>&1, stderr-only redirect, log to file with curl -fsS” class=”wp-image-5735″/></figure>



<h2 id=Keep error emails only
# Drop stdout, keep stderr -> cron emails on errors only
* * * * * wget http://www.example.com/cron.php >/dev/null

# Or with curl, fail-on-HTTP-error so you actually hear about 500s
* * * * * curl -fsS http://www.example.com/cron.php >/dev/null

With only stdout silenced, anything the job writes to stderr (errors, warnings) is still captured by cron and emailed to the crontab owner — exactly when you’d want notification.

Log to a file instead

# Append everything to a log
* * * * * wget http://www.example.com/cron.php >> /var/log/myapp-cron.log 2>&1

# Rotate with logrotate to keep it from filling the disk

>> appends, so each run adds to the same file. Pair with logrotate so the log file doesn’t grow forever.

For local PHP scripts

# Run a PHP script directly, no HTTP round-trip
* * * * * /usr/bin/php /var/www/html/cron.php >/dev/null 2>&1

Running the script locally is faster than fetching it over HTTP and skips the whole web stack. Use the full path to php — cron’s PATH is minimal.

wget‘s own quiet flag

# --quiet suppresses wget's normal output (its progress bar, save messages)
* * * * * wget --quiet --output-document=/dev/null http://www.example.com/cron.php

Combine --quiet with --output-document=/dev/null to silence both the progress messages and the saved file. Cleaner than shell redirection when you want to be explicit, but >/dev/null 2>&1 works on any command.

Frequently asked questions

What does 2>&1 actually mean?

2>&1 redirects file descriptor 2 (stderr) to wherever file descriptor 1 (stdout) is currently going. Order matters: >/dev/null 2>&1 first sends stdout to /dev/null, then sends stderr to the same place. Flipping it to 2>&1 >/dev/null sends stderr to the original stdout (the terminal), then sends only stdout to /dev/null — usually not what you want.

Why does cron email me every time my job runs?

Cron’s default behaviour: any output to stdout or stderr is captured and emailed to the crontab owner via sendmail. >/dev/null 2>&1 silences that. If you want to keep email only on errors, set [email protected] in the crontab and redirect only stdout: >/dev/null. Errors still go to stderr, cron captures them, you get an email.

Should I use wget or curl for HTTP-triggered cron?

Either works. curl -fsS is slightly nicer: -f exits with a non-zero status on HTTP errors (so cron can detect failures and email you), -s silences the progress meter, -S still shows real errors. The cron line becomes: * * * * * curl -fsS http://example.com/cron.php >/dev/null. If curl fails, cron emails the error and you find out.

Is it bad practice to run cron via HTTP?

Has trade-offs. Pros: the cron host doesn’t need PHP/dependencies installed — just curl/wget. Cons: requests go through the full web stack (slower), the endpoint must be reachable, and unauthenticated cron endpoints can be hit by anyone who knows the URL. Either authenticate the endpoint (a shared secret in the URL or header) or run the script locally with * * * * * /usr/bin/php /path/to/cron.php.

Related guides

  • How to Run a Cron Job as a Non-Root User
  • How to Set Up a System-Based Cron Job for WordPress
  • How to Schedule a Cron Job in WordPress Without a Plugin

References

man 5 crontab on any Linux. Bash redirection: gnu.org/software/bash/manual/html_node/Redirections.html. logrotate: github.com/logrotate/logrotate.

TAGGED:BashcronLinux

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Set and get cookies with JavaScript How to Set and Get Cookies with JavaScript
Next Article Store a PHP array in a MySQL database with JSON How to Store a PHP Array in a MySQL Database
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026
Tailscale mesh — peer-to-peer connections between devices, coordination server
How to Install Tailscale on Ubuntu (Zero-Config Mesh VPN for Self-Hosters)
May 24, 2026

You Might Also Like

Fix DKIM not signing emails in aaPanel
Server Management

How to Fix DKIM Not Signing Emails in aaPanel

5 Min Read
Linux add and delete users from the terminal — adduser, passwd, sudo group, userdel
Server Management

How to Add and Delete Users on a Linux Server from the Terminal

7 Min Read
Change SSH port on Linux — firewall, SELinux, sshd_config, systemctl restart
Server Management

How to Change the Default SSH Port on Linux

7 Min Read
MySQL top CPU usage — PROCESSLIST snapshot and performance_schema digest
Server Management

How to Check Which MySQL Database or User Is Using the Most CPU

8 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?