Main » 2015 » May » 2 » Save users' crontabs to files
12:22 PM Save users' crontabs to files |
Simple bash script to save all users' crontabs to files. Quite handy when need to inspect what jobs are scheduled to run on a system. The script can be helpful when you need to migrate or back up your Linux system. It goes through the list of all users on a Linux system and saves whatever all existing crontabs to files. I have it tested on Amazon Linux AMI and on Ubuntu. It also shall work on whatever RedHat family system, like Fedora, CentOS, Simply Linux. Basically whatever supporting "crontab -l -u <user>" shall do. Copy-paste the bash code to a file. chmod the file to be executable. Run it as root or with sudo. #!/bin/bash while read line do u=`echo "$line" | cut -d: -f1` c=`crontab -u $u -l` if [ $? == 0 ]; then echo "$c" > "$u.ct" echo "saved crontab for $u to $u.ct" fi done < /etc/passwd |
|
Total comments: 0 | |