1753814 Members
8003 Online
108805 Solutions
New Discussion юеВ

hwo to use cron tab

 
SOLVED
Go to solution
Punithan
Advisor

hwo to use cron tab

hello now i got to get the report of netstat -s
for every 30 minit .
now hwo to to it using n cron tab and swave it in one folder
System Engineer
4 REPLIES 4
MANOJ SRIVASTAVA
Honored Contributor

Re: hwo to use cron tab

Hi

1.log in as root
2.crontab -e
3.add the following line

30 * * * * /usr/bin/netstat -s >> log file

this will update the log file every 30 mts.

4. Please do check the cron bu crontab -l

Also please clean up the log file where the info is stored regularly so that you dont end have 100 % full filesystems.

You can create a shell script to write the time stamp too

Manoj Srivastava
Victor_5
Trusted Contributor

Re: hwo to use cron tab

crontab -e

0, 30 * * * * /usr/bin/netstat -s >> your_filename

Rita C Workman
Honored Contributor
Solution

Re: hwo to use cron tab

First you can create a very simple script:

vi

#/bin/sh
#
#
echo "********************"
echo "Command ran:"date
echo "********************"
netstat -s >> /dirpath/netfile.log

Save the file..
chmod 770

Now edit your existing cronfile and add a line:

crontab -e
00,30 * * * * /dirpath/ > /dev/null 2>&1


The job newfile-name simply runs the command and append the results to file /dirpath/netfile.log.
The entry in your cronfile will run every 30 minutes of every hour of every day of every month....I didn't bother to log any messages in cron.

Rgrds,
Rit
S.K. Chan
Honored Contributor

Re: hwo to use cron tab

Quick and dirty .. as root ..

# crontab -e
===> edit and add this line.

00,30 * * * * { date; netstat -s; } >> /tmp/data

# crontab -l
===> check it