Record server uptime in text file
Create a shell script and execute that shell script. TODAY=$(date +"%T") SCRIPT=$(uptime | awk '{print $(NF-2)" "$(NF-1)" "$(NF-0)}') echo "$TODAY | $SCRIPT" >> /root/script/out.txt
Create a shell script and execute that shell script. TODAY=$(date +"%T") SCRIPT=$(uptime | awk '{print $(NF-2)" "$(NF-1)" "$(NF-0)}') echo "$TODAY | $SCRIPT" >> /root/script/out.txt
Make a shell script file. nano script_benchmakring.sh #!/bin/bash echo `date` > /home/log.txt sleep 5 echo `date` >> /home/log.txt You can place any command in the script in place of "sleep 5". We are using sleep command to verify everything is working fine and time difference is being recorded. Now we will make this script executable chmod +x...
We will create a bash script and run via cron job and set the time as per your requirement. If you don't know how to create bash script, please read "How to create Linux bash script" #!/bin/bash # Shell script to restart MySQL server if it is killed or not working # due...
Launch a terminal vi, nano or any other prefered editor of your choice. I will be using nano as a editor. nano /home/bash-scripts/my-first-script.sh At the top type the following code #!/bin/bash. This is known as a Shebang line. #!/bin/bash echo "start of script" ls echo "end of script" This script prints a header line then list...