How to keep a job running in Linux Rumi, November 13, 2017November 13, 2017 There are many ways to keep a process running on linux but I haven’t seen any that are as easy to implement as the script below. Basically the script does a ps ax and then a grep for your process. If it’s not running it will re-start the process. You install the script into… Continue Reading
IP Setting on CentOS6 using Shell Script Rumi, December 6, 2015 #!/bin/bash if [ $# -eq 5 ] then echo “” echo “Taking the backup and Changing the hostname from $(hostname) to $1 …” sed -i.bk “s/$(hostname)/$1/g” /etc/sysconfig/network echo “” echo “Backing up & Assigning the Static IP …” echo “” cp /etc/sysconfig/network-scripts/ifcfg-$2 /etc/sysconfig/network-scripts/$2.bk cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$2 DEVICE=$2 BOOTPROTO=static IPADDR=$3.$4… Continue Reading
Bash Shellshock fix with scripts for Debian, Ubuntu, CentOS and other distros. including old Rumi, October 3, 2014December 19, 2014 First check if your Bash is vulnerable, execute the following command- env x='() { :;}; echo vulnerable’ bash -c ‘echo this is a test’ If your system is vulnerable, you will see: vulnerable this is a test If your system is not vulnerable, you will see: bash: warning: x: ignoring… Continue Reading
CRON scripts to running in seconds interval Rumi, June 6, 2014 This problem can be solved with simple bash script. For example, if you need to run a PHP script on every 20 seconds, you can create a bash script like this: #!/bin/bash #Name:myscript.sh #Desc:Run script in every 20 seconds while (sleep 20 && php /path_to_your_script/your_script_name.php) & do wait $!… Continue Reading
Send HTTP requests using cURL Rumi, June 6, 2014 Reading a URL via GET: curl http://example.com/ Defining any HTTP method (like POST or PUT): curl http://example.com/users/1 -XPUT Sending data with a request: curl http://example.com/users -d"first_name=Bruce&last_name=Wayne" If you use -d and do not set an HTTP request method it automatically defaults to POST. Performing basic authentication: curl http://user:password@example.com/users/1 All together… Continue Reading