Servers will also be set to accomplish duties or run scripts robotically. In Linux, you’ll use the cron application to configure the duty or scripts your server must run at a specified time. Any cron jobs in your server are situated within the spool directories within the /var/spool/cron/crontabs. The crontab lists all cron jobs for customers, except the foundation person. However, if you want to view the cron jobs of all of the device, you will have to be a root person.
This article covers how you’ll listing all jobs in crontab for the device, present customers, and different customers. Sounds excellent? Let’s get began.
How To List cron Jobs
The crontab lists jobs in line with a person, and with an administrator privilege, you might view jobs of some other person.
1. Viewing Cron Jobs for Current User
When making a cron activity, specify which person the scheduled activity falls beneath. If no person is specified, the crontab record schedules the activity for the lately logged person. In that case, you’ll use the next command to listing the scheduled jobs for the present person:
In the next output, you’ll observe the scheduled jobs indexed on the backside of the record:
2. Viewing All Cron Jobs of Another User
To view the roles of some other person, you utilize the -u flag adopted through their username. Also, you’ll want administrator privilege for this to paintings. For example, the next command perspectives the cron jobs of a person named linuxhint1.
$ sudo crontab -l -u linuxhint1
Your goal person’s jobs will likely be displayed in a crontab record like the only proven beneath:
3. Viewing All cron Jobs as Root
The crontab within the spool listing doesn’t listing the roles for the foundation person. To view the crontab containing the quite a lot of jobs for the entire device, open the /and so on/crontab record.
The earlier output lists the entire cron jobs for all of the device. Note that there are 4 classes of device jobs. The hourly, day by day, weekly, and per month jobs. If you wish to have to edit the device crontab, you’ll open it the usage of an editor like nano. The command for that may be as proven beneath. Note that you just will have to be a root person to get entry to the crontab record.
To view the entire hourly cron jobs, run the next command:
# ls -la /and so on/cron.hourly
In the former output, we don’t have any hourly cron activity. By default, you must get a outcome very similar to the only above with two directories and the .placeholder, which is helping keep away from the unintended deleting of directories in your device through the package deal supervisor.
To view the day by day cron jobs, use the next command:
You can observe the day by day jobs for quite a lot of device processes within the earlier output.
Similarly, the next command lists the entire weekly cron jobs.
# ls -la /and so on/cron.weekly
Lastly, you’ll view the device’s per month cron jobs the usage of the next command:
# ls -la /and so on/cron.per month
We handiest have one per month cron activity, as proven above.
4. Viewing Cron Jobs for Specific Applications
It’s conceivable to listing the cron jobs for the quite a lot of programs working in your device. Here, you’ll select the class to view the particular software. For example, the next command perspectives the day by day cron activity for Google Chrome:
# cat /and so on/cron.day by day/google-chrome
Working with cron to automate scripts and jobs to your Linux device or server is fantastic. We’ve lined the quite a lot of techniques you’ll listing the entire crontab jobs, together with for the present person, some other person, and dealing with root to get device cron jobs. Further, we mentioned how it’s essential listing the hourly, day by day, weekly, and per month jobs. Try it out and spot your cron jobs.