Using cron to schedule tasks is a good way to automate things on your computer. It saves you time by letting the system handle repeated tasks for you. Cron jobs run automatically. You just have to set the time they should run, like daily, hourly, or weekly.
These tasks are saved in a special file called a crontab (short for “cron table”). This file tells the system what to run and when. Crontab logs help you see if these tasks ran successfully and let you spot any problems.
In this article, you’ll learn what crontab logs are, how to find and read them, and how to fix common issues. We’ll also look at how tools like Middleware can make it easier to track your cron jobs.
Understanding Crontab Logs
Crontab logs are records that show the execution details of your cron jobs. Implementing consistent log formatting ensures that these logs are structured for easier parsing and analysis, enhancing your ability to monitor and troubleshoot scheduled tasks effectively. They help you check whether a task ran successfully or failed. These logs also identify and report errors that occurred during execution. Tasks you can schedule with crontab include:
- Backing up files
- Sending emails
- Cleaning temporary files
- Executing scripts
- Running data report
You need crontab logs to monitor these tasks. Without the logs, you can’t tell if everything is going well or not.
What Information Do Crontab Logs Contain?
As mentioned earlier, Crontab logs provide useful details about each task you execute. Here is the information you’ll find in the crontab log:
- Timestamp: Shows when the task was executed.
- Hostname: Name of the computer where the log entry was recorded.
- Process: Indicates that the log came from the cron service, along with its process ID.
- Log Message: Describes what cron was doing at the time, like starting a job or logging an error.
Where to Find Crontab Logs
Crontab logs are saved in your system’s log files, but the exact spot depends on the operating system you’re using.
Default System Log Locations
Each OS has its default location for storing cron-related logs. Here are the most common ones:
1. Linux (Debian/Ubuntu)
On Debian-based systems, cron jobs are stored in the system log file /var/log/syslog
. This file stores many system-level logs, including those from cron. You can filter all cron entries using:
grep cron /var/log/syslog
This will filter and display logs that have the word “cron.”
Output:

2. Linux (RHEL/CentOS)
Cron logs on Red Hat-based systems are stored in a dedicated file called /var/log/cron
. This makes monitoring easier, as it only contains scheduled tasks. To view cron-related logs, run:
grep cron /var/log/cron
Alternatively, you might also find them in:
grep cron /var/log/messages
Similar to Ubuntu, it will display the execution time and commands of each cron job.
3. macOS
macOS does not log cron job output by default. It has to be configured manually. However, you can still find basic cron messages in the general system log:
grep cron /var/log/system.log
You might see when a job starts or other related system messages. By default, anything your cron job prints goes to your email. But if you rarely check your email, it’s easy to miss something. A better option is to save the output to a log file that you can quickly review anytime.
Custom Log Paths
To better track your cron jobs, you can send their output to a specific log file. This helps you catch any messages or errors. Here’s how:
* * * * * /path/to/script.sh >> /home/your-username/myscript.log 2>&1
Let’s break down this command:
- * * * * * represents the cron schedule. The format is “Minute Hour Day Month DayOfWeek.” So in our example, the script runs every minute of every hour, every day. If we have something like 0 2 * * *, it would run the job every day at 2 AM.
- * * * * *
│ │ │ │ │
│ │ │ │ └── Day of Week (0 – 6) (Sunday=0)
│ │ │ └──── Month (1 – 12)
│ │ └────── Day of Month (1 – 31)
│ └──────── Hour (0 – 23)
└────────── Minute (0 – 59)
- * * * * *
/path/to/script.sh
is the script or command you want to run. You can replace it with your actual script or command.- >> appends output to the specified file instead of overwriting it like “>”.
/home/your-username/myscript.log
is the file that stores the standard output (stdout). If it doesn’t exist, it will be created automatically. Replace [your-username] with your system username.- 2>&1 redirects standard error (stderr) to the same location as stdout. 2 is the file descriptor for standard error, and 1 is the file descriptor for standard output. So, 2>&1 means “send error messages to the same place as the normal output.”
How to Interpret Crontab Logs
When you run a cron job, a record is left behind. You can use these to check if your job ran, when it ran, and if it was successful or not.
Reading the Logs
You can check logs using commands like grep
or journalctl
. We’ve been using grep in earlier sections, so we know what it looks like.
grep cron /var/log/syslog #For Ubuntu/Debian
grep cron /var/log/cron #For RHEL/CentOS
You’ll see output like this:
Apr 22 12:25:30 marvel cron[1270]: (CRON) INFO (Running @reboot jobs)
- Apr 22 12:25:30 is the time the job ran.
- marvel is your system’s hostname
- cron[1270] is a process ID assigned by cron.
- (CRON) INFO (Running @reboot jobs) message itself. INFO is just an informational message (not an error or warning), and Running @reboot jobs means cron is now starting any scheduled jobs that were set to run at system boot (@reboot keyword in crontab).
Using journalctl (for systems using systemd)
On newer versions of Ubuntu or CentOS, cron logs may be managed by systemd. You can check cron logs with:
journalctl -u cron
This command shows cron-related messages. You can scroll through the output to find your job’s execution record.
Learn how to monitor and troubleshoot services using systemctl logs.
Successful vs. Failed Jobs
Crontab logs do not display “Success” or “Failed” directly. Instead, if a job runs without issues, it logs the command execution and moves on, but if something goes wrong, errors are often sent to your email or appear in the system logs. To make sure errors are saved in a log file, run the command:
/path/to/script.sh >> /home/your-username/output.log 2>&1
Then open output.log
to see if there’s an error message or if everything ran correctly.
Troubleshooting Common Issues
Sometimes, things might go wrong with your cron jobs, but crontab logs can help you figure out what happened. Below are some common issues and how to fix them:
No Logs Found
If you can’t find any logs, these might be a few reasons:
- Wrong log location: Your system might log cron activities in a different file than the one you’re trying to access. You can visit the system log files to see if they were logged there.
grep cron /var/log/syslog # For Ubuntu/Debian
grep cron /var/log/cron # For RHEL/CentOS
journalctl -u cron # For systemd-based systems
These commands will search through the system log files and find entries related to cron jobs, so you can see if they were even triggered.
- Cron service is not running: You have to make sure cron is running on your computer. On systemd-based systems, run:
sudo systemctl status cron
This checks whether the cron service is running on your machine.
- No output generated: If your script or command doesn’t have any output or errors, nothing may appear in the log unless you redirect the output manually.
Permission Errors
Cron runs with limited permissions, depending on the user:
- Access to files or folders: If a cron job tries to read/write to a location it doesn’t have access to, it will fail. Example:
* * * * * /var/log/syslog >> /var/log/myscript.log 2>&1
bash: /var/log/myscript.log: Permission denied
We are having this error because /var/log/syslog
is usually readable only by root. /var/log/myscript.log
is also in a protected system directory, which is usually writable only by root. Try a different location.
* * * * * /path/to/script.sh >> /home/your-username/myscript.log 2>&1
- Root vs. user crontab: Jobs that run in the root crontab might fail for a regular user crontab because of access restrictions.
Environment Variable Differences
Cron jobs in a different environment than your terminal. This can lead to issues, especially if your script needs environment variables such as PATH to function well.
To fix this:
- You can add environment variables directly in your script or crontab file. For example:
PATH=/usr/bin:/bin:/usr/local/bin
- Or use the full path to all commands in your script (like
/home/your-username/output.log
instead of justoutput.log
).
Always test your script manually first. Then add logging (>> /path/to/log 2>&1) to capture both output and errors when the job runs from cron.
Best Practices for Managing Crontab Logs
Below are some best practices you should follow for proper cron log management.
Use Descriptive Log Filenames
Make sure the name of the log file is clear and describes its purpose. Avoid general names like log.txt
because they don’t explain what the log is for. Instead, choose names such as daily_backup.log
or cleanup_temp_files.log
. This way, you can quickly see which task each log is related to.
Log Output to Files for Audit Trails
Redirecting output to log files helps you keep a history of what happened during each task. This is useful for auditing, troubleshooting, or even proving that a job ran successfully.
Rotate Logs (Avoid Bloating)
Log files can grow quickly, especially if a cron job runs frequently. If you don’t manage them, your storage can get bloated. Use tools like logrotate to automatically archive and clean up old log files. This keeps your system clean and avoids running out of disk space.
Explore our guide on log management best practices to ensure your system remains optimized and secure.
Alerting on Failed Jobs Using Observability Tools
If a cron job fails and no one knows about it, the whole point of automation is lost. Set up alerts using observability platforms like Middleware to notify you when something goes wrong. You can configure them to watch for keywords like “error” in your log files.
Monitor Logs
Log monitoring tools (for example, Middleware) help you collect, visualize, and search through logs easily. These tools can show trends, spot failures, and help with debugging, all in one place.
Using Middleware to Enhance Cron Job Logging
Crontab logs are valuable because they enable you to debug and keep track of automated jobs, but in the absence of monitoring, errors will not be noticed. Middleware can assist you in simplifying the way you deal with such logs.
Rather than manually looking at various locations for logs, Middleware offers a single location where you can view all your cron job logs in a single dashboard.
Learn more about Middleware Log Explorer feature.
It also provides live notifications, which tell you if something has failed or taken too long. With this, you do not have to wait until you manually check the logs to determine if there is a problem.

Working with tools like Middleware makes it easier to handle cron logs efficiently. Its user-friendly interface and features help you track job performance and catch errors faster.
How to Monitor Crontab Logs with Middleware
In this section, we’ll walk through a simple step-by-step guide for setting up Middleware and viewing your crontab logs on the dashboard.
1. Create an account
First, create an account on Middleware. This lets you use the dashboard to view your logs and set up alerts.
2. Install the Middleware agent on your Linux machine
Middleware requires an agent running on your system to collect logs. Use the correct installation command based on your system type.
For Debian/Ubuntu:
MW_API_KEY="<MW_API_KEY>" MW_TARGET=https://<MW_UID>.middleware.io:443 bash -c "$(curl -L https://install.middleware.io/scripts/deb-install.sh)"
For RHEL/CentOS:
MW_API_KEY="<MW_API_KEY>" MW_TARGET=https://<uid>.middleware.io:443 bash -c "$(curl https://install.middleware.io/scripts/rpm-install.sh)"
Replace <MW_API_KEY>
and <MW_UID>
with the actual values from your Middleware account.
3. Verify the installation
Once the agent is installed, confirm that it’s running properly:
sudo systemctl status mw-agent
You should see a message indicating that the agent is active and running.

4. View your logs on the Middleware dashboard
Go to your Middleware dashboard and click on the logs icon. For detailed steps, refer to our docs on Log Monitoring Overview.

Here you can find all your logs. They contain the date, time, log type, and messages of your cron jobs.

Middleware actively monitors your system logs, such as /var/log/syslog
or /var/log/cron
. If your logs are stored somewhere else, you can tell Middleware to track those too.
Conclusion
In conclusion, we’ve covered the basics of crontab logs, such as what they are, their importance, and how to use them. They help you check if your scheduled tasks are running the way they should.
To simplify the process, Middleware can centralize all your log data, provide alerts, and effectively monitor cron jobs. If you want to enhance the way you handle cron jobs, Middleware is a useful tool worth considering..