Linux: My Bash Script Collection / Server Configurations

1. Restart apache daily. Put in /etc/cron.daily directory.

#!/bin/bash
#/usr/bin/systemctl restart httpd
#/usr/bin/systemctl start httpd

for (( ; ; ))
do
echo "checking"
sleep 120
if [ `ps auxwwww|grep httpd|grep -v grep|wc -l` -gt 0 ]
then
echo Apache is running.
break
else
echo Apache is not running.
/usr/bin/systemctl start httpd
fi

done

2. Set Limit File Size Per User Using Limits.conf

#example : limit file size ~100MB per file per user
#create file in /etc/security/limits.d/99-hafez.conf
#enter details below:
--------------- BOF ------------------
# hard fsize
hafez hard fsize 100000
--------------- EOF -----------------
#save the file
#-- tested on centos 6.9

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s