Kind of a noob question but I'm looking to have my networking daemon (wicd), run every day on my machine, only from 5am-6am and 6pm-7pm, regardless of when my machine was turned on, in other words, if the process is running while it's not that time of the day, I need it to terminate. What would be the least hacky way to do this. Obviously if I use crontab and write a cronjob where wicd is run at 5am and 6pm, and e.g. killall gets rid of it at 6am and 7pm, this would cause a problem, because if I start my machine at 5:04am wicd will not run initially, so I could make wicd run, or not run, at init time by writing an init script for it (my init's SysV), where I check the current time of day, this seems like it should cut it, but is this workaround the only way to approach this issue, or is there a simpler way to make sure the program is running only at the specified time regardless of the time my machine was turned on.


One way would be to use CFEngine, with a policy approximately like so:

bundle agent mybundle {

        service_policy => "start";

        service_policy => "stop";


The default CFEngine run interval is every five minutes (with a delay in there so a fleet of hosts won't all have it run at the same moment), so in your example, after starting your computer at 5:04 a.m., within 5 minutes the service would be running. Then on the next run of CFEngine after 6:00 a.m. (sometime between 6:00 and 6:05), the service would be stopped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.