Sponsored Content
Full Discussion: Scheduling cron job
Operating Systems Linux Red Hat Scheduling cron job Post 302823759 by Just Ice on Wednesday 19th of June 2013 08:16:31 PM
Old 06-19-2013
or you could just let the script sleep every 5 seconds ... start it from cron every start of the hour ... script sample below wil exit if $lockfile exists ... removing lockfile will kill running script ...
Code:
#! /bin/ksh
lockfile=/tmp/lockfile

repeatJob(){
    echo "boo"
    echo "duh\n"
    if [ ! -f $lockfile ]
    then
        break
    else
        sleep 5
        repeatJob
    fi
}

if [ ! -f $lockfile ]
then
    touch $lockfile
    repeatJob
else
    echo "$lockfile exists. Exiting."
    exit 1
fi

exit 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem with scheduling a job

I scheduled 2 Oracle jobs to run on IBM AIX 4.3.3 at 06:50 and 06:58 on 02/02/03 with the below syntax: $ at 06:50 02/02/03 /orac/ora11/temp/sun_job1.sh Job oracle.1044175800.a will be run at Sun Feb 2 06:50:00 2003. $ at 06:58 02/02/03 /orac/ora11/temp/sun_job2.sh Job... (1 Reply)
Discussion started by: ted
1 Replies

2. Shell Programming and Scripting

Job Scheduling

Hello, I want to know about job scheduling utilities available in unix. It should not be responsible just for starting the job like in case of cron but should also be able to handle the execution of jobs. Regards, Ritesh (1 Reply)
Discussion started by: turlapaty
1 Replies

3. UNIX for Advanced & Expert Users

cron job scheduling

Hi, How can I configure cron file , to execute a script on evey alternate saturdays ? I am using AIX 5.0 machine Thanks in advance Shihab (1 Reply)
Discussion started by: shihabvk
1 Replies

4. UNIX and Linux Applications

Job Scheduling

I am working on UNIX AIX system, with Oracle OS. We are not supposed to use any tools to schedule our unix shell scripts. Basically we have to make use of Oracle tables and Shell scripts to manage dependencies, restartability, scheduling, parallelizing,etc. If anyone has worked/ is working... (1 Reply)
Discussion started by: singhabhijit
1 Replies

5. Shell Programming and Scripting

Job Scheduling

I am working on UNIX AIX system, with Oracle OS. We are not supposed to use any tools to schedule our unix shell scripts. Basically we have to make use of Oracle tables and Shell scripts to manage dependencies, restartability, scheduling, parallelizing,etc. If anyone has worked/ is working... (4 Replies)
Discussion started by: singhabhijit
4 Replies

6. UNIX and Linux Applications

Job Scheduling (Autosys)

Hello! I will be working with Autosys and I am looking for individuals that have knowledge of this UNIX application. Thank-you! (3 Replies)
Discussion started by: preshe79
3 Replies

7. Shell Programming and Scripting

Scheduling Cron job-Problem

Hello All, I want to run a script for every 5 minutes interval.So i developed a script which has to be scheduled to run for every 5 minutes. That script internally runs another script. But the problem is it is not executing properly. Can anybody throw some light on this. Below are the code... (4 Replies)
Discussion started by: RSC1985
4 Replies

8. Shell Programming and Scripting

Cron Job Scheduling

Hi All, I have a script which is scheduled in the Cron. It runs every 10th and 40th min of an hour.The job has to run every 30min. But, I do not want to have the 00:10 MST run every day.Is it possible to exclude that run from the schedule?Or any other way through which i can run my job every... (4 Replies)
Discussion started by: sparks
4 Replies

9. Shell Programming and Scripting

scheduling a job using at command

Hi All, I've been trying to schedule a job using the at command on Solaris 5.10 but i've been running into some issue. ( Not allowed to use cron :wall: ) I have a script that reads a logs file, does some iteration and cat's the output in an email . ## the o/p of /home/myscript.sh is : ... (2 Replies)
Discussion started by: Irishboy24
2 Replies

10. Shell Programming and Scripting

Job Scheduling

Hi All, I am new to unix and i have a task in front of me. The code part is "android update sdk" . I need to crontab this process. Hence i have written a script that runs the above command and sends a mail once the update is done. The problem with the automation is the installer asks for a... (5 Replies)
Discussion started by: Kashyap
5 Replies
maillock(3MAIL) 					  User Mailbox Library Functions					   maillock(3MAIL)

NAME
maillock, mailunlock, touchlock - functions to manage lockfile(s) for user's mailbox SYNOPSIS
cc [ flag ... ] file ... -lmail [ library ... ] #include <maillock.h> int maillock(const char *user, int retrycnt); void mailunlock(void); void touchlock(void); DESCRIPTION
The maillock() function attempts to create a lockfile for the user's mailfile. If a lockfile already exists, and it has not been modified in the last 5 minutes, maillock() will remove the lockfile and set its own lockfile. It is crucial that programs locking mail files refresh their locks at least every three minutes to maintain the lock. Refresh the lockfile by calling the touchlock() function with no arguments. The algorithm used to determine the age of the lockfile takes into account clock drift between machines using a network file system. A zero is written into the lockfile so that the lock will be respected by systems running the standard version of System V. If the lockfile has been modified in the last 5 minutes the process will sleep until the lock is available. The sleep algorithm is to sleep for 5 seconds times the attempt number. That is, the first sleep will be for 5 seconds, the next sleep will be for 10 seconds, etc. until the number of attempts reaches retrycnt. When the lockfile is no longer needed, it should be removed by calling mailunlock(). The user argument is the login name of the user for whose mailbox the lockfile will be created. maillock() assumes that user's mailfiles are in the ``standard'' place as defined in <maillock.h>. RETURN VALUES
Upon successful completion, .maillock() returns 0. Otherwise it returns -1. FILES
/var/mail/* user mailbox files /var/mail/*.lock user mailbox lockfiles ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
libmail(3LIB),attributes(5) NOTES
The mailunlock() function will only remove the lockfile created from the most previous call to maillock(). Calling maillock() for different users without intervening calls to mailunlock() will cause the initially created lockfile(s) to remain, potentially blocking subsequent message delivery until the current process finally terminates. SunOS 5.10 29 Mar 1999 maillock(3MAIL)
All times are GMT -4. The time now is 01:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy