Skip to content
View in the app

A better way to browse. Learn more.

Gear Crushers

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Check Cron Jobs for all users

Featured Replies

Manual method is by user running a command like



crontab -u userName -l

NOTE: If you run the above command without -u userName you would show the cron for root


 


Also check /etc/crontab by running



less /etc/crontab

Also you can view the daily cron jobs by running




cd /etc/cron.daily/
ls -l
cat filename

NOTE: You can also view monthly, weekly and hourly but just replacing the word daily in the above command with either monthly or weekly or hourly


 


Last but not least, any software package specific cron you can view by running




cd /etc/cron.d/
ls -l
cat filename


Of course all that is a pain because you have to go to so many places.  Maybe the script below will be easier


 



This bash script will show all users cron jobs




#!/bin/bash


# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'


# Single tab character. Annoyingly necessary.
tab=$(echo -en "t")


# Given a stream of crontab lines, exclude non-cron job lines, replace
# whitespace characters with a single space, and remove any spaces from the
# beginning of each line.
function clean_cron_lines() {
while read line ; do
echo "${line}" |
egrep --invert-match '^($|s*#|s*[_]+=)' |
sed --regexp-extended "s/s+/ /g" |
sed --regexp-extended "s/^ //"
done;
}


# Given a stream of cleaned crontab lines, echo any that don't include the
# run-parts command, and for those that do, show each job file in the run-parts
# directory as if it were scheduled explicitly.
function lookup_run_parts() {
while read line ; do
match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}S+ )*S+')


if [[ -z "${match}" ]] ; then
echo "${line}"
else
cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
cron_job_dir=$(echo "${match}" | awk '{print $NF}')


if [[ -d "${cron_job_dir}" ]] ; then
for cron_job_file in "${cron_job_dir}"/* ; do # */
[[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}"
done
fi
fi
done;
}


# Temporary file for crontab lines.
temp=$(mktemp) || exit 1


# Add all of the jobs from the system-wide crontab file.
cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"


# Add all of the jobs from the system-wide cron directory.
cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */


# Add each user's crontab (if it exists). Insert the user's name between the
# five time fields and the command.
while read user ; do
crontab -l -u "${user}" 2>/dev/null |
clean_cron_lines |
sed --regexp-extended "s/^((S+ +){5})(.+)$/1${user} 3/" >>"${temp}"
done < <((cut --fields=1 --delimiter=: /etc/passwd && find /home/ -maxdepth 1 -mindepth 1 -type d -printf "%fn") | sort | uniq)


# Output the collected crontab lines. Replace the single spaces between the
# fields with tab characters, sort the lines by hour and minute, insert the
# header line, and format the results as a table.
cat "${temp}" |
sed --regexp-extended "s/^(S+) +(S+) +(S+) +(S+) +(S+) +(S+) +(.*)$/1t2t3t4t5t6t7/" |
sort --numeric-sort --field-separator="${tab}" --key=2,1 |
sed "1imithtdtmtwtusertcommand" |
column -s"${tab}" -t


rm --force "${temp}"


Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.