Linux special commands file3
Linux special commands file3
===================================================================================
============================================
51) crontab
- The ‘Crontab’ Linux Command goes on to check the time on the device and
when a particular time arrives,
it performs pre-defined tasks automatically.
- Crontab works by allowing the users to schedule tasks or commands that help
to run automatically at specified times and intervals.
MIN (Minute) --> Specifies the minute when the command will run
It ranges from 0 to 59.
HOUR --> Denotes the hour of the day when the command is scheduled to
execute.
It spans from 0 to 23.
DOM (Day of Month) --> Specifies the day of the month for the task.
It ranges from 1 to 31.
MON (Month)--> Indicates the month during which the command will be
executed.
It varies from 1 to 12.
DOW (Day of Week)--> Specifies the day of the week for the task.
It is represented by numbers from 0 to 7, where both 0 and 7 correspond
to Sunday.
CMD (Command)
Represents the actual command or script that will run at the scheduled
time.
Ex:
* * * * * CMD
--> The * means all the possible units — i.e. every minute of every
hour throughout the year.
More than using this * directly, you will find it very useful in
the following cases.
When you specify */5 in the minute field means every 5 minutes.
When you specify 0-10/2 in the minute field means every 2 minutes
in the first 10 minutes.
Thus the above convention can be used for all the other 4 fields.
3) To Schedule a Job For More Than One Time (e.g. Twice a Day):
00 11, 16 * * * /home/maverick/bin/incremental-backup
--> 00 – 0th Minute (Top of the hour) 11, 16 – 11 AM and 4 PM * –
Every day * – Every month * – Every day of the week
Cron Job every day during working hours: This example checks the
status of the database every day (including weekends)
during the working hours 9 a.m – 6 p.m
00 09-18 * * * /home/maverick/bin/check-db-status
--> 00 – 0th Minute (Top of the hour) 09-18 – 9 am, 10 am, 11 am,
12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
* – Every day * – Every month * – Every day of the week
*/10 * * * * /home/maverick/check-disk-space
--> It executes the specified command check-disk-space every 10
minutes throughout the year.
===================================================================================
============================================
52) mail
===================================================================================
============================================
53) bc
Syntax:
ex:
Input : $ echo "12+5" | bc
Output : 17
===================================================================================
============================================
54) sed
- SED command in UNIX stands for stream editor and it can perform lots of
functions on file
like searching, find and replace, insertion or deletion.
Though most common use of SED command in UNIX is for substitution or for
find and replace.
By using SED you can edit files even without opening them, which is much
quicker way to find and replace something in file,
than first opening that file in VI Editor and then changing it.
Syntax:
sed OPTIONS... [SCRIPT] [INPUTFILE...]
Syntax:
$ sed 'nd' filename.txt
Example:
$ sed '5d' filename.txt
Syntax:
$ sed '$d' filename.txt
Syntax:
$ sed 'x,yd' filename.txt
Example:
$ sed '3,6d' filename.txt
Syntax:
$ sed 'nth,$d' filename.txt
Example:
$ sed '12,$d' filename.txt
Syntax:
$ sed '/pattern/d' filename.txt
Example:
$ sed '/abc/d' filename.txt
===================================================================================
============================================
55) awk