CAll Us: USA +1 9176775553   Login

backup script for reseller account

Following are the steps to take increment backup of reseller account on backup server. 1) First we need to find out the user name which is under the reseller account. On shared/source server :- vi /home/resellerUsername/backup.sh # For finding the username under the reseller account cat /etc/trueuserowners | grep resellerUsername | awk -F: ‘{print $1}’ […]

Read More »

find out the reseller name with domains

How to find out the reseller name with domains? Ans : If you want to list all cPanel accounts under a specific reseller, then you can use the below simple shell script. 1) Crete the file reseller.sh and add the following code. vi /home/reseller.sh ========================================================== #!/bin/bash usage() { echo “Example : $0 domain.com or username” […]

Read More »

terminate old suspended accounts

Question : How to terminate old suspended accounts on cpanel server ? Ans:  You can terminate the 90 days old suspended accounts by using the following script. 1) vi /root/terminatesuspended.sh ================== for i in `find /var/cpanel/suspended/ -mtime +90 | cut -d’/’ -f5 | sed ‘1 d’` do y | /scripts/killacct $i –killdns n; done; ================== […]

Read More »

Script to automatically start nginx

You can use the following script to auto restart the nginx on the server. The following script check the status and if it is down then it restart. You can set cron  “* * * * * /bin/sh /root/autongnixrestart.sh” ========================== #! /bin/sh set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC=”nginx daemon” NAME=nginx DAEMON= /usr/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME test -x $DAEMON || exit […]

Read More »

Script to automatically start mysql

The following script is used to  start mysql automatically when it is failed or stopped on the server. You can set 2 min cron “*/2 * * * * /bin/sh /root/automysqlstart.sh” and it restart the mysql automatically. ============================ #!/bin/bash #Checking whether MySQL is alive or not if mysqladmin ping | grep -q “alive”; then echo “MySQL is […]

Read More »

script to check NFS mount point

How to check NFS mount point by using the script ? Ans : If you we have mounted the NFS directory one or  more servers and you want to monitor that mount point then you can use the following method. 1) Check the mount point directoy name, in the following example the mount directory name […]

Read More »

Script to restart any service automatically

We can set the cron to restart the server when it was down or not running. You can use following script to detect and restart the httpd,ngnix,Serv-U or any other services. 1) Create the file vi /root/autorestart.sh and add the following code and save it. You can replace the Serv-U with any your service like […]

Read More »

Make your shell colorful

You can easily changed your black ssh screen to colorful screen by using following steps. 1) Login to the server via SSH as root 2) Edit the .bash_profile file found in the /root directory & paste the following line: vi  .bash_profile export PS1=”\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]” Save & quit the […]

Read More »

email when access the server

It’s always a good practice & from the security point of view to get notified instantly through an email when someone logs into your server through SSH with root privileges. Open the file .bashrc for the root user. Vi /root/.bashrc enter the following code into echo ‘SSH Root Access (Your Server Name) on:’ `date` `who` […]

Read More »

Some common script

1 ) Script to change server wide ownership for all cpanel users. ==================== #!/bin/bash cd /var/cpanel/users for user in * do chown -Rv $user.$mail /home/$user/etc chown -v $user.$nobody /home/$user/public_html chown -Rv $user.$user /home/$user done ====================

Read More »

Set expiration for you index page

If you want to set the expiration to your site   means after some date or year your site shows custom error on the page then you can add following code in index page below the “<?php” code  and set the date as per your request. ============================================ $exp_date = “2010-04-31”; $todays_date = date(“Y-m-d”); $today = […]

Read More »

set correct ownership to all accounts

How to set correct ownership to all account on the cPanel server. You can use the following commands to set the correct ownership for all accounts which is hosted on the cPanel server. =============================== for i  in `cat /etc/trueuserdomains   | awk ‘{print $2}’` > do > chown $i.$i /home/$i -R; > chown $i.mail /home/$i/etc -R; […]

Read More »

test cgi script

Create one test.cgi file and add the folloing test code for checking the .cgi file working on the server. ======================= #!/usr/local/bin/perl # hello.pl — my first perl script! print “Content-type: text/html\n\n”; print “Hello, world!\n”; =======================

Read More »

some IMP script

1) Script for finding username from /etc/trueuserowners file and save it user.txt file cat /etc/trueuserowners | awk ‘{print $2}’ > user.txt or cat /etc/trueuserdomains | awk ‘{print $1}’ > user.txt 2) Script for remove .htaccess or any file from current(.) directory find . -name .htaccess | xargs rm -rf

Read More »

Script for create package on cpanel server

If you want to migrate more accounts from one server to another server then you need to create packages for each accounts . You can easilly create packages by using this script. 1) Create one Migarting-Accounts.txt file and add the the user name , which you want to create packages. 2) Create Migration directory for […]

Read More »