LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Only starting command in a specific time period (https://www.linuxquestions.org/questions/linux-software-2/only-starting-command-in-a-specific-time-period-207164/)

jeroenvrp 07-19-2004 07:40 PM

Only starting command in a specific time period
 
Hi,

How do one starts a command after the time and date mets a specific condition.

Example:

- I'm booting Linux and it's starting all the processes in the various runlevels.
- There is one proccess (command) that must only start on saturday, sunday and monday night, during 18h00 and 23h00 .
- So it checkes the time and if it's for instance saturday evening 22h10 it will start command A. If it's for instance Wednesday afternoon 14u30 the command B will start.

So i'm not talking about the 'at' command and also not about 'cron'.

Hopefully someone can helps me with this issue. Personally I think it can be done with a little bit of shell-scripting, but I don't know how and searching Google gives to much results.

Cheers,

Jeroen

osvaldomarques 07-19-2004 10:09 PM

Hi jeroenvrp,
I think you are talking about cron. If you read the manual for crontab, which is the front end for cron, you will see that you can specify a minute, hour, day of week, day of the month and month to precisely start your job, if your machine is running at the time. The at command is to specify one delayed job. Cron is to specify cyclic executions of the same job.

jeroenvrp 07-20-2004 08:00 AM

Thank you for your answer, but this is not a cron issue unfortunately.

The command is in the crontab on 18h00 (it switch off internet-access):
- This works great when the PC is on, but when the PC is off or the PC is rebooted after 18h00 the Internet access will be restored, because it's in the default boot sequence (init.d).
- So I want to run this command (to switch off internet-access) when the PC is booted between 18h00 and 23h00.

If cron has an option while it starts on boot to run not-performed tasks, it would be great, but according my knowledge it's not possible.

Cheers,

Jeroen

osvaldomarques 07-20-2004 11:18 PM

Code:

* 18-23 * * sat-mon check-internet-connection >/dev/null 2>&1
This crontab will run the "check-internet-connection" every minute in the range. It may be a script to check "ps ax | grep -c apache" to see if it is running and kill it if needed. Depending on the way the script is written it won´t load for instances you already have internet down and your computer will be glad to serve you.


All times are GMT -5. The time now is 12:24 AM.