Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
yes,
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 http://search.cpan.org/author/JGLICK...lib/SGI/FAM.pm
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):
#!/bin/sh
TESTFILE="/tmp/runit.dat"
if [ -f ${TESTFILE} ]; then
command1
command2
command3
fi
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.