Hello! I'm Justin with LiquidWeb. Automation is an important part of
server administration. In the world of Linux servers the utility cron is chief
among the tools utilized to automate repetitive tasks. In this video, we'll
take a look at how to check out what jobs are scheduled on a Linux server.
Knowing how to find out the tasks that are scheduled to run on a Linux box will
help you make informed decisions about what else you might want to automate.
Let's get started. One thing to note during this tutorial, I am logged into my
linux server as the root user. For simplicity it would be best if you are
logged into your Linux server as the root user to avoid any permissions
issues that may arise when running commands or viewing files specified in
this video. Cron jobs can exist in a number of different places; First let's
take a look at the crontab. In order to see the cron jobs created by the current
user you can enter the command crontab - L As you can see the root user on this
Linux server has no scheduled jobs at this time in crontab You can also view
any other users jobs in crontab. Enter crontab - u followed by the username
of the user you want to check followed again by the L flag. In my case there is
a user on my Linux server called J Tobias I'll go ahead and enter crontab -
you J Tobias - L and concede that J Tobias has one job scheduled in crontap
The Jobs on crontab are located on the filesystem at the path /var/spool/cron
If I run the ls command on that directory
ls /var/spool/cron I can see that there is a file called JTobias
If I check the contents of that file less /var/spool/
/cron/JTobias I can see the same information that crontab - u JTobias -l
provided. Cron jobs can also be set up via the various cron directories in
/etc Let's take a look at each one in turn.
A quick note; The scripts in your cron directories might not be exactly the
same as the scripts in mine. To view all the daily cron jobs you can run the
command ls - la /etc/cron.daily. To look at a specific daily cron job. You
can run the less command on any of the files in that directory. Next, we can take
a look at all of the hourly cron jobs. To do so,
run the command ls - la /etc/cron.hourly. And again, to look at any of the
specifics of a given job, you can run the less command on any of the files in this
directory. To view all of the weekly cron jobs, you can run the command ls - la/
etc/cron.weekly, and take a look at the listing. Finally, you can take a look
at the cron jobs scheduled to run on a monthly cadence by running ls - la /etc/
/cron.monthly. There is yet one more location in the /etc directory
where you can find scheduled cron jobs and that would be the file /etc/
/crontab. You can view the contents of that file and get an idea of what jobs
are associated with it by running the command less /etc/crontab.
Now that you know where to look to find the scheduled cron jobs on your Linux server,
if you're looking to get a handle on how to leverage cron you can head over to
https://liquidweb.com/kb/ and search for how to
automate server scripts with cron there you have it.
You now know where to look to find scheduled cron jobs on your Linux server