?
Solved

How to schedule a task for certain period of time

Posted on 2003-03-25
8
Medium Priority
?
342 Views
Last Modified: 2013-12-15
I want to schedule a command to run as a background job on each morning and wanna end it at midnight without using the kill command. Is there any way to use any command which will run for a specified period of time. Say from 9:00 a.m to 23:00 p.m. and then stops automatically because we people can't use the kill command in the server because boss doesn't allow it.
0
Comment
Question by:redhat_786
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Expert Comment

by:edey
ID: 8208904
might it be easier to have your script, or what have you, periodically check the time? That way you could use cron to start the job, and let the script take care of cleaning up after itself

GL
Mike
0
 

Author Comment

by:redhat_786
ID: 8209068
There's nothing in the script but a single command i.e. "tail -f file1 > file2 & " which fetches only the appended data from the file and store it in the file2. It runs as a background job and I want to stop it working at midnight and then start it again on next morning as a new process.
0
 
LVL 4

Expert Comment

by:bobgunzel
ID: 8213477
Tail is not a daemon and will exit after it is finished.
So just make a crontab entry like:
*/10 9-23/1 * * * tail -f file1 > file2  
It will be executed every 10 minutes from 9 a.m. to 11 p.m.
Bob Gunzel
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:redhat_786
ID: 8215545
Sir, actually I want to schedule it to run as a background job and if I schedule it to run after ten minutes then it would return only ten last lines even if it has added more than 10 lines in the file which is made by online coming data. So please help me in this cause so that it keeps on running for a specified period of time. Thanks
0
 
LVL 4

Accepted Solution

by:
bobgunzel earned 160 total points
ID: 8218224
You can daemonize any program by using daemontools,
http://cr.yp.to/daemontools.html. You can control the execution period with crontab and the svc program that comes with deamontools.
I recommend to use a script with a sleep statement. Otherwise disk-io and cpu usage may serverely hamper other
applications.

Bob Gunzel
0
 

Expert Comment

by:CleanupPing
ID: 9076588
redhat_786:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question