Date command options.
Date command to get the current date.
$ date=$(date +%Y-%m-%d)
$ echo $date
Date command to get yesterday's date.
$ date=$(date --date=yesterday +%Y-%m-%d)
$ echo $date
Date command to get tomorrow's date.
$ date=$(date --date=tomorrow +%Y-%m-%d)
$ echo $date
Performing arithmetical operations on date.
Below example will subtract 1 hour from the current date time.
$ strdate=`date --date=now +"%s"`
$ strdate=`expr ...
Some time our system started to use more swap area even 100% of swap area and the system crashes. So for a System Admin it would be very helpful when they get informed if the system started to use more swap usage so that system admin can manage the server before crashing. So I wrote a shell script which will Alert by send mail if the ...
The below script will check the hard disk space usage, using the command du and send an email alert if any of the partition is using more than 85% of space.
vim disk-usage.sh
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print ...
In Ubuntu we don't have a mechanism to start or stop iptables or we don't have a mechanism to restore iptables after restarting the system. Now we will see how to create a script for start and stop iptables also to make the script to start on system startup.
1. Create a Firewall script
vim /etc/set_iptables.bash
echo 1 > ...
#!/bin/bash
cd /home/shahid/ # Change the dectory to the specified location
monit stop all # Stop all the process
rm -rf log/* # Deletes all the files inside the directory log
rm -rf dump/processed/* # Deletes all the files inside the directory ...
Introduction
One of the more powerful tricks of the .htaccess is the ability to rewrite URLs. This enables us to do some mighty manipulations on our links; useful stuff like transforming very long URL's into short, cute URLs, redirecting URL to some other URL, transforming dynamic ?generated=page&URL's into /friendly/flat/links, redirect missing pages, preventing hot-linking, performing automatic language translation, and much, much ...