Check system cron jobs in /etc/cron.d
In the previous step, you learned how to view cron jobs for a specific user. Now, let's explore system-wide cron jobs.
System-wide cron jobs are typically stored in the /etc/cron.d/
directory. Unlike user crontabs, which are managed with the crontab
command, system-wide cron jobs are defined in individual files within this directory.
These files are often created by installed software packages to schedule tasks that need to run for the entire system, such as system updates, log rotation, or cleanup scripts.
To view the files in the /etc/cron.d/
directory, you can use the ls
command. Since this directory is owned by the root user, you'll need to use sudo
to list its contents.
Type the following command in the terminal and press Enter:
sudo ls /etc/cron.d/
You might see output similar to this, listing various files:
anacron e2scrub_all phpsessionclean
The specific files you see may vary depending on the software installed on the system. Each file in this directory represents a system-wide cron job configuration.
To view the content of one of these files, for example, phpsessionclean
, you can use the cat
command. Again, you'll need sudo
because the file is owned by root.
Type the following command and press Enter:
sudo cat /etc/cron.d/phpsessionclean
You will see the contents of the file, which define when and how the phpsessionclean
script is executed. The format is similar to a user crontab, but it also includes a user field to specify which user should run the command (often root
).
## This file is installed by the php-common package
#
## The script will clean up old session files.
#
## See /usr/lib/php/sessionclean for details.
09,39 * * * * root [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi
This output shows that the phpsessionclean
script is scheduled to run at minute 09 and 39 of every hour, every day, and it will be executed by the root
user.
Exploring the files in /etc/cron.d/
helps you understand what automated tasks are running at the system level.
Click Continue to move to the next step.