The cron service searches its spool area (usually /var/spool/cron/crontabs) for crontab files (which are named after user accounts); crontabs found are loaded into memory. cron also reads /etc/crontab, which is in a slightly different format. Additionally, cron reads the files in /etc/cron.d: it treats the files in /etc/cron.d as in the same way as the /etc/crontab file.
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | Yes |
Requirements | Linux |
Time | 2m |
Linux View Users Cronjob
Use the following syntax to view vivek users cronjob:
sudo crontab -u userName -l sudo crontab -u vivek -l
How to Display all jobs in cron / crontab
I run the following as root user:
crontab -l
View Root User Cronjob on Linux
Just type the following command as root user:
crontab -l
OR
sudo crontab -l
Sample outputs:
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command #* * * * * root /root/bin/master.replication @reboot /bin/sleep 100;/bin/systemctl restart memcached
How to view /etc/crontab on Linux or Unix
A cronjob can be also run from /etc/crontab file. To view it run the following less command:
# less /etc/crontab
Sample outputs:
# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
Linux view daily cronjob
Type the following commands to display daily crontab:
cd /etc/cron.daily/ ls -l cat filename cas passwd
Linux view running daily cron jobs
Unix view hourly cronjobs
Type the following commands:
cd /etc/cron.hourly/ ls -l cat filename
How to view Weekly Cron jobs on Linux
Type the following commands:
cd /etc/cron.weekly/ ls -l cat filename
Command to see monthly Cronjobs / crontabs
Excute the following cat command to see running cron jobs:
cd /etc/cron.monthly/ ls -l cat filename
View Software (Package) Specific Cronjobs
Run the following commands
cd /etc/cron.d/ ls -l cat filename cat renew-ssl-certs
Listing users cron jobs when using systemd timers
Systemd comes with its cron system called systemd.timer. It is another option that one can use on systemd based Linux distro. Use the systemctl command as follows to list cron jobs in Linux
systemctl list-timers
Pass the --all option to see loaded but inactive timers, too:
systemctl list-timers --all
What to do when you get a list of all scheduled cron jobs on your system?
Now you know how to list the cron jobs on your Linux or Unix server or VM. Make sure you backup all cron jobs too. Typically I backup the following in directories:
- /var/spool/cron/
- /var/spool/anacron/
- /etc/cron*
Summing up
You learned how to list, display, and view all current Linux cron jobs. See the following tutorials for more info:
- What is cron on a Linux or Unix-like systems?
- How To Add Jobs To cron Under Linux or UNIX?
- Verify crond Daemon And Cronjobs Are Running
- Start Restart and Stop The Cron or Crond Service
- List / Display All Cron Jobs
- Linux / UNIX Crontab File Location
- Change Crontab Email Settings ( MAILTO )
- Disable The Mail Alert By Crontab Command On a Linux or Unix-like Systems
- At What Time Cron Entries In cron.daily, cron.weekly, cron.monthly Run?
- Execute Cron Job After System Reboot
- Setup and Run PHP Script As A Cron Job
- Run crontab job every minute on a Linux or Unix-like system
- Running crontab (cron jobs) Every 10 Minutes
- Cron Job Script Execution on the Last Day of a Month
- Execute / Run crontab (cron jobs) every 1 minute
- Ubuntu create cron.log file
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 10 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thank you for a very good summary. If a cron task is required to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d/ directory.
view crontab from all users:
cat /var/spool/cron/*
crontab -l just lists the jobs for the user who ran the command.
So, to view root’s jobs, you’d either need to be logged in as root or run it with sudo.
There is also very handy script to view all users crontabs. Run it as follows to list all cron jobs for user:
1219738668600575d442dd5_000010
How do we check running cronjob process.
I guess, its from ps -ef | grep file.sh
or any other suggestion.
To check running cronjob process use:crontab -l
To list all user’s crobtab:
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
How does one check the “version” of cron running? How can one know if their cron is a “vixie-style” crontab or not?
Try the following:
1219738668600575d442dd5_000011
I do this task manually
./getConfig ‘indirect’ ‘./(Command task)’ ‘./(Credential.csv’ ‘/usr/cronout/’ (standalone server)
in command task there is a “cat /etc/ssh/sshd_config” but I saw blank sshd_config even though I can see details about sshd_config when I run those task manually. Can you help me?