Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Setup a cron job and specified the start and end time Post 302566205 by agama on Wednesday 19th of October 2011 07:48:52 PM
Old 10-19-2011
If I were doing this, I'd kick off a script at 18:40, just once, and let it run your programme/script every three minutes until midnight.

Code:
#!/usr/bin/env ksh

while true
do
    d=$( date +%H )
    if (( $d == 0 ))
    then
        exit
    fi

    echo "run your command here"
    sleep 180
done

Your crontab entry would be simple:
Code:
40 18 * * * /path/to/your/script.ksh >/tmp/script.log 2>&1

If the command you are running takes several minutes to run, and you want it to start right at the next three minute mark, run it asynchronously (use &) so that the waking from the sleep is 3 minutes from when the programme started and not three minutes from when the programme ended.

Last edited by agama; 10-19-2011 at 08:55 PM.. Reason: clarification
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job at system start up

I want to know if there is a way to make a certain set of programs start in order at system startup with cron or something else i dont know about. (3 Replies)
Discussion started by: rcunn87
3 Replies

2. UNIX for Advanced & Expert Users

cron does not start the need job

Hi, can you please help me with one problem? There is some server, there are a lot of AIX applications which run on this server under different UserIDs. These applications starts via crontab. From time to time some application doesn't start. What can this "not-action" be dependent on? At... (5 Replies)
Discussion started by: Anta
5 Replies

3. UNIX for Dummies Questions & Answers

Setup Cron Job

Hello, I would like setup a CRON job to rename my server's name (host name) every day. For some reason it changes its own name every couple days to server-2.local fron server.local. Thank you! -Chris (3 Replies)
Discussion started by: christo16
3 Replies

4. Shell Programming and Scripting

Start time/end time and status of crontab job

Is there anyway to get the start time and end time / status of a crontab job which was just completed? Of course, we know the start time of the crontab job since we are scheduling. But I would like to know process start and time recorded somewhere or can be fetched from a command like 'ps'. ... (3 Replies)
Discussion started by: thambi
3 Replies

5. Solaris

How to setup a cron job to run every 45 minutes in Solaris 5.10

How to setup a cron job to run every 45 minutes in Solaris 5.10 (9 Replies)
Discussion started by: reyazan
9 Replies

6. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

7. Shell Programming and Scripting

setup cron job

HI I am new to unix . I wanted to create a cron job that runs a script every 10 min .So when I enter vi /etc/crontab I get the following output SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * *... (1 Reply)
Discussion started by: ptappeta
1 Replies

8. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

9. HP-UX

How to end script in a cron job?

I've created a script to copy backup files from an HP-UX 11iv3 system to an NFS share on another machine. I want to schedule the script to run via cron. The script is simply three lines of cp /backups/Backup /shared/Backup. I've saved the script as a .sh file and call it with KSH. Do I need to... (3 Replies)
Discussion started by: jduehmig
3 Replies
queuedefs(4)							   File Formats 						      queuedefs(4)

NAME
queuedefs - queue description file for at, batch, and cron SYNOPSIS
/etc/cron.d/queuedefs DESCRIPTION
The queuedefs file describes the characteristics of the queues managed by cron(1M). Each non-comment line in this file describes one queue. The format of the lines are as follows: q.[njobj][nicen][nwaitw] The fields in this line are: q The name of the queue. a is the default queue for jobs started by at(1); b is the default queue for jobs started by batch (see at(1)); c is the default queue for jobs run from a crontab(1) file. njob The maximum number of jobs that can be run simultaneously in that queue; if more than njob jobs are ready to run, only the first njob jobs will be run, and the others will be run as jobs that are currently running terminate. The default value is 100. nice The nice(1) value to give to all jobs in that queue that are not run with a user ID of super-user. The default value is 2. nwait The number of seconds to wait before rescheduling a job that was deferred because more than njob jobs were running in that job's queue, or because the system-wide limit of jobs executing has been reached. The default value is 60. Lines beginning with # are comments, and are ignored. EXAMPLES
Example 1: A sample file. # # a.4j1n b.2j2n90w This file specifies that the a queue, for at jobs, can have up to 4 jobs running simultaneously; those jobs will be run with a nice value of 1. As no nwait value was given, if a job cannot be run because too many other jobs are running cron will wait 60 seconds before trying again to run it. The b queue, for batch(1) jobs, can have up to 2 jobs running simultaneously; those jobs will be run with a nice(1) value of 2. If a job cannot be run because too many other jobs are running, cron(1M) will wait 90 seconds before trying again to run it. All other queues can have up to 100 jobs running simultaneously; they will be run with a nice value of 2, and if a job cannot be run because too many other jobs are running cron will wait 60 seconds before trying again to run it. FILES
/etc/cron.d/queuedefs queue description file for at, batch, and cron. SEE ALSO
at(1), crontab(1), nice(1), cron(1M) SunOS 5.10 1 Mar 1994 queuedefs(4)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy