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
Run Laravel queue workers with Supervisor
How to Run Laravel Queue Workers in Production with Supervisor
May 23, 2026
Nginx as a reverse proxy for a Node.js app on Ubuntu
How to Set Up Nginx as a Reverse Proxy for Node.js on Ubuntu
May 23, 2026
Install and configure Redis on Ubuntu for Laravel and WordPress
How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)
May 23, 2026
Harden a fresh Ubuntu VPS with UFW, Fail2Ban, and SSH key auth
How to Harden a Fresh Ubuntu VPS: UFW + Fail2Ban + SSH Key Auth
May 23, 2026
Set up Let's Encrypt SSL with Certbot on Ubuntu
How to Set Up Let’s Encrypt SSL with Certbot on Ubuntu (Apache & Nginx)
May 23, 2026

You Might Also Like

Laravel .htaccess exclude .well-known for Let's Encrypt ACME challenge
Server Management

How to Exclude .well-known from Redirection for Let’s Encrypt in Laravel

8 Min Read
Install Laravel on Ubuntu — terminal with composer create-project command and Laravel red-pillar icon
Web Development

How to Install Laravel on Ubuntu: Step-by-Step Guide

9 Min Read
Check Linux OS name and version from the command line
Server Management

How to Check the Linux OS Name and Version from the Command Line

4 Min Read
Laravel rollback specific migration — Artisan migrate:rollback --path command illustration
Web Development

How to Rollback a Specific Migration in Laravel

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?