how to schedule job to run 30mins if script contains tail -f

how to schedule job to run 30mins if script contains tail -f

Post by kaedeRukawa.. » Mon, 26 Jun 2006 03:12:44



Hi all,

I am learning linux and shell programming.

I would like to monitor a log file using tail -f

however, I would like to run this only 30mins and then send the log
file out.  How can I do that?

script:
#!/bin/bash

#monitoring sys.log and write output to txt
tail -f sys.log >> sys.txt

# send it out to someuser
grep -i "string" sys.txt
mail

I would like to put this on as a cron job, so it will execute on a
certain day for only 30mins.
Can anyone help?  Thanks in advance.

Kaede

 
 
 

how to schedule job to run 30mins if script contains tail -f

Post by base6 » Mon, 26 Jun 2006 03:40:36



> Hi all,

> I am learning linux and shell programming.

> I would like to monitor a log file using tail -f

> however, I would like to run this only 30mins and then send the log
> file out.  How can I do that?

Konichiwa,

"man at"

 
 
 

how to schedule job to run 30mins if script contains tail -f

Post by Chris F.A. Johnso » Mon, 26 Jun 2006 03:34:31



> Hi all,

> I am learning linux and shell programming.

> I would like to monitor a log file using tail -f

> however, I would like to run this only 30mins and then send the log
> file out.  How can I do that?

> script:
> #!/bin/bash

> #monitoring sys.log and write output to txt
> tail -f sys.log >> sys.txt

> # send it out to someuser
> grep -i "string" sys.txt
> mail

> I would like to put this on as a cron job, so it will execute on a
> certain day for only 30mins.

tail -f sys.log >> sys.txt &
sleep 1800
kill $!

--
   Chris F.A. Johnson, author              <http://cfaj.freeshell.org>
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   ===== My code in this post, if any, assumes the POSIX locale
   ===== and is released under the GNU General Public Licence

 
 
 

1. Run a scheduled job every day, how? cron?

Hi there,
I am sort of a cron newbie, and while I know it does some housekeeping,
I'd like to know how to make it do something of my own (if that is
possible).

I'd like to have th system once a day (or week) run through the
drive and remove any core files that have appeared.

I could put a .logout file in for each user to to that, but
it would only reliably get whatever was in their user directory.

Can I have cron run a :

find / core | rm -f -

or something (I haven't thought about the safest way to do it yet).

Related:
Is there a way to have the cron log only print errors and not
successfull completions of jobs?  I don't necessarily want it
to redirect to /dev/nul

Thanks!
TTFN
Gregg
--
    __
   /// Gregg Le Blanc: http://eci2.ucsb.edu/~gregger Santa Barbara

\\X/      When life gives you limes, make a kiln out of them!

2. Possible mknod() bug over NFS?

3. Dealing with filenames containing IFS characters

4. crash

5. job scheduling shell script

6. - IRQs and aha152x installation

7. how to run a script containing a remote shell command in the background??

8. 200203250946

9. restarting a linux server running apache with a scheduled script.

10. schedule a task to run a korn shell script

11. Jobs, Jobs, Jobs And More Jobs!!!