Dealing with Crontab

Schedule tasks under Linux is an powerful procedure which is used by almost everyone, and to do this using program called cron. more about it here .

Procedure :

make a new text file, and enter this line in that text file like the below :-

crontab myfirstjob

Formatting crontab file :-

what this file contains

Number
Meaning
Allowed range
1
Minutes
0-59
2
Hours
0-23
3
Days
1-31
4
Months
1-12 OR First 3 letters of the Month name
5
Days of the week
0-7 OR First 3 letters of the Day name
6
Name of the program
Any program

Some useful command can be used with cron :-

Show all the task running under cron.

crontab -l

edit the crontab

crontab -e

Some example from crontab file :-

# Minute   Hour      Day of Month       Month                 Day of Week        Command  
# (0-59)     (0-23)     (1-31)             (1-12 or Jan-Dec)    (0-6 or Sun-Sat)              
    0               12           *                             *                         *            /u01/backup.sh

For more example about crontab press here

Cheers
Osama Mustafa

Script to Restart the OEM Agent When It Has Failed

Gaurav Batta has published this nice script to restart the OEM agent when it has failed:

$ cat agent_check.sh
#!/usr/bin/ksh
#
agent_status=`ps -ef|awk ‘{print $8}’|grep agent10g/bin/emagent`

if [[ -z $agent_status ]]
then
$AGENT_HOME/bin/emctl start agent
echo Agent started on server `hostname` at `date`
else
echo Agent is running fine on server `hostname` at `date`
fi

It is running every 30min.
crontab –l

00,30 * * * * /home/oemagent/agent_check.sh >> /home/oemagent/agent_status.log




Enjoy 


Thank you
Osama Mustafa