Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-18-2003, 03:38 PM   #1
Registered: Sep 2002
Posts: 184

Rep: Reputation: 30
a script that runs every 5 minutes?

is it possible to do a script that check a text file every five minutes, and if something is there, run a few commands?

Old 08-18-2003, 03:53 PM   #2
Senior Member
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
Create your script.
And then using cron, you can schedule the script to run at specific times or intervals.

Automated Tasks
Old 08-18-2003, 03:54 PM   #3
LQ Veteran
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Sure. If you can write the script you want, you just need to make it executable and set it up as a cron job. Have a look at the crontab manual entry to find out how to execute a program every five minutes.
Old 08-18-2003, 03:57 PM   #4
Registered: Jun 2003
Location: Europe, Latvia
Distribution: Slackware
Posts: 44

Rep: Reputation: 15
try to, use crontab (see man pages, or look in this forum, there should be some discusion about it)
or make in script infinitive loop with `sleep 300` command to wait 5minutes and do those commands You need.
There is also such thing as `FAM` it use fs notifications to track the creation of file (maybe also the changes of file, i dunno, i read today in mailing list about it )
Perl module using FAM can be found here

hope smth. will help!

Last edited by v3rb0; 08-18-2003 at 04:12 PM.
Old 08-18-2003, 03:59 PM   #5
LQ Newbie
Registered: Feb 2003
Distribution: RH7,RH8,Slack
Posts: 29

Rep: Reputation: 15
Yep, sure is.

You have to first create the script to check for the existence of the file, and run the commands. If you're not familliar with shell scripting, here's a basic template (bash):


if [ -f ${TESTFILE} ]; then

This script will look for the file called /tmp/runit.dat and will execute command1, command2, and command3 in succession if the file does exist.

The next thing you have to do is schedule the script to run every 5 minutes in cron (if you're unfamilliar with cron, man cron provides documentation.

Basically you'll want to add a line to your crontab file. Edit your crontab file (see manpage), and add the following line anywhere in the file:

5 * * * * /your/new/script/filename

where the /your/new/script/filename is, obviously, the location of the script file you created above, and the number 5 means "run every 5 minutes".

Install the crontab (again, see manpage) and you're good to go!

hope this helps.....
Old 08-19-2003, 12:14 AM   #6
Registered: Sep 2002
Posts: 184

Original Poster
Rep: Reputation: 30
coool!!! I managed to have everything working perfectly thanks to you guys!

I love you all, thx for your big help, the links and the basic scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
a script that runs wget every 3 minutes Menestrel Programming 3 07-26-2005 11:22 AM
logout after script runs bigdog0007 Linux - Newbie 6 06-24-2005 05:42 PM
howto run a script from cron every 5 minutes except 11pm-8am ? cccc Programming 2 03-20-2005 03:52 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
Where can I the script that runs the forum? patpawlowski LQ Suggestions & Feedback 5 03-17-2004 04:37 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration