Bash Script: How to show cron jobs for all users

Valic —  February 11, 2013 — Leave a comment

This script will send you an email that contains all cron jobs for all your users.

#!/bin/bash
# Show all users cron jobs and send a report via email
# Created by [email protected], no rights reserved.
# Please submit feedback and questions at [email protected]
# Homepage: http://www.debian-tutorials.com

EMAIL=$1
if [ -n "$EMAIL" ] ; then
	TMPFILE=/tmp/cronjobs.tmp.$$

        #get all users list
	for i in `cat /etc/passwd | cut -f1 -d :`; do
		echo "##################################################"
		echo "Username: ${i}"
		echo "##################################################"
		crontab -u ${i} -l 2>&1
		echo "##################################################"
	done > $TMPFILE
	cat $TMPFILE | mail -s "Cronjobs report for `hostname`" ${EMAIL}
	rm -f $TMPFILE
else
	echo "Usage: ./cronlist your_email_address"
	exit
fi

You can download this script directly from here: How to show cron jobs for all users

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply