Skip to main content

Posts

Showing posts from February, 2010

Backup of CRON list and jobs

#!/bin/bash # Author: haritux.in # To be ran as root or SUDO echo Enter the destination directory for backup read DEST OUT=`hostname`_crons.`date +%d%m%Y-%H%M%S` mkdir -p $DEST/$OUT 2&> /dev/null cd $DEST/$OUT for i in `ls /var/spool/cron/crontabs/`  ### Debian, Ubuntu #for i in `ls /var/spool/cron/`  ### Red Hat, CentOS, Fedora    do       grep $i /etc/passwd      if [ $? = 0 ]; then         {         crontab -u $i -l >> $i.cronlist.txt         }      fi    done cd .. tar -czf $OUT.tar.gz2 $OUT rm -rf $OUT

SSH Launcher

#!/bin/bash echo Select the hostname to SSH HOSTS=/home/psychotux/scripts/conf/hosts.txt cat $HOSTS | cut -f3 -d'|' read host echo Enter your username number IP=`grep $host $HOSTS | cut -f2 -d'|'` ssh "$user"@$IP Note: /home/psychotux/scripts/conf/hosts.txt will be a file with values HOSTNAME and IP ADDRESS separated by "|"