As a server administrator, you might want to follow-up which account has suspended for days and it’s the time for you to terminate it.
With a smart system administrator(lazy actually), you may have a custom script to check any of your account that been suspended for more than 2 months may terminate from the server automatically to save the resource/space from the server.
From this article, Mick Genie will guide you how to write a shell script and create it from the cronjob, however this step could only done by the root user.
1. Create a file name autoterminated_within60days.sh from /root/scripts/.
2. Insert the following code and save it.
for i in `find /var/cpanel/suspended/ -mtime +60 | cut -d’/’ -f5 | sed ‘1 d’`
y | /scripts/killacct $i;
3. Create a cronjob, by typing crontab -e in SSH.
4. Type as following line in the crontab to apply daily checking.
0 0 * * * /bin/sh /root/scripts/autoterminated_within60days.sh
Assume that you are using crontab to schedule your task which you are using Unix system.
To schedule a database backup, it will be very easy as step below.
1. Log into your SSH.
2. Type “crontab -e” without quote.
3. Enter the command below.
0 0 * * * date=`date -I` ; mysqldump -a -u[user] -p[password] [dbname] | gzip > /path/folder/[dbname]_$date.sql.gz
where you shall replace the user, password and dbname to your database information.
With the command as above it will actually backup your database by 12.00AM daily and place to the desired path and name with date.
Crontab also known as schedule task in Windows Operating System and it is very important for you to schedule your automated script run from anytime without actually taking care on those script time by time in front of your server/PC.
All of the time, vi editor have set as the default editor for crontab and if you like Mick Genie that not like vi but like nano/pico, you may actually change the editor as step below.
Continue reading Change crontab editor