Sponsored Content
Full Discussion: interval in a launchd script
Operating Systems OS X (Apple) interval in a launchd script Post 302297821 by choogendyk on Sunday 15th of March 2009 09:13:37 PM
Old 03-15-2009
Doesn't look like you're getting much response here.

I understand that launchd is intended to replace cron, among other things. And I haven't really looked at that aspect of launchd. I have created stuff that runs at startup with it.

What you are talking about has two components. One is the basic running things every 2 hours. If you've got that, then ok. I'd be inclined to just toss it in cron, because that still works.

The other aspect is how to deal with the previous instance still being running. If you create your own shell script, instead of directly running rsync, then you can do a couple of different things. One of the more common approaches is to implement a pid file. When the script runs, it checks to see if the pid file exists. If it does, the script terminates, with maybe a log or error message. If it doesn't it creates it. Then when it is done, it removes it.

So, something like

echo $$ > /var/run/runrsync.pid

would put the process id of the current script into that location.

Anyway, after the book keeping, the script would launch rsync.

Part of the reason I didn't respond sooner was that I don't know what facilities launchd has built in for managing this sort of thing. I could be giving you an outdated solution to something that launchd has solved more elegantly.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script Run Interval to be dynamic

Hi All. I have a script which has to be run periodically. The frequency of its run will be decided by a Database stored value PollRate. e.g. If PollRate value is 300secs, then the script should be executed every 5 minutes, if it's 1500secs, it should execute every 15 minutes. Is there... (5 Replies)
Discussion started by: rahulrathod
5 Replies

2. Shell Programming and Scripting

script to run repeatedly after a fixed interval of time

Hi , I am working on the following script . I want this script to run and scan the log file repeatedly after 3 hours. This script will run & scan just for the current date logs and after every 3 hours. Kindly advice what to add in this script for this purpose. #!/bin/sh diff common.log... (3 Replies)
Discussion started by: himvat
3 Replies

3. Shell Programming and Scripting

run script 1 minute interval without CronTab

I am using Solaris 9. I wish to run my script every 1 minute inteval. Though i can run it using below entry in crontab. * * * * /export/home/username/script/file_exist_&_run.sh in short above script will check whether a specific file exist in a directory. If it found it will inovke another... (10 Replies)
Discussion started by: thepurple
10 Replies

4. UNIX for Dummies Questions & Answers

Run script in the background with a time interval

I have a script I want to run in the background, and I have looked it up but I am not exactly sure how to do. First of all to run it in the background do you have to put something in the script or is it just a command when you go to run it. I found this solution to it but once again I am not to... (2 Replies)
Discussion started by: mauler123
2 Replies

5. Shell Programming and Scripting

compare the interval of 2 numbers of input2with interval of several numbers of input1

Help plz Does any one have any idea how to compare interval ranges of 2 files. finding 1-4 (1,2,3,4) of input2 in input1 of same key "a" values (5-10, 30-40, 45-60, 80-90, 100-120 ). Obviously 1-4 is not one of the range with in input1 a. so it should give out of range. finding 30-33(31,32,33)... (1 Reply)
Discussion started by: repinementer
1 Replies

6. OS X (Apple)

[launchd] Creating a basic firewall

Hi, I'm trying to use launchd to detect whether certain ports are opened and if they are then to take some appropriate action, e.g. close the port or, worst case scenario, down the whole net connection. Apparently, force closing a port is not possible without killing the offending binary so... (3 Replies)
Discussion started by: ASGR
3 Replies

7. Shell Programming and Scripting

Calculate packet in/out interval script

Hello I'm trying to find interval for packet IN/OUT for a gateway. log looks like: 02.12.2011 16.28.29:200 PDU IN CI:424 TRID:200 ID:N/A EID:N/A EX:N/A PDU:0000001f0000000100000000000000c874746f700074746f70000034010100 02.12.2011 16.28.29:228 PDU OU CI:424 TRID:200 ID:N/A EID:N/A EX:ACK... (3 Replies)
Discussion started by: samer.odeh
3 Replies

8. UNIX for Dummies Questions & Answers

Launchd-owned processes unexpected behavior

Ok, so I have been struggling with this for a few days and I think I need an explanation of a few things before I go any further. I'm not sure it's possible to do what I'm trying, so before I pull my hair out, here is what I'm doing: I have written a program in LiveCode that sits on our... (2 Replies)
Discussion started by: nextyoyoma
2 Replies

9. Shell Programming and Scripting

Expect command when triggered by launchd

Hi folks, Im having trouble with an expect command in a shell script I use to back up mac os x servers. This one is being run on a 10.8.2 Server as part of a larger bash script. The script executes perfectly all the way through when triggered on the command line, but when launchd triggers it at... (4 Replies)
Discussion started by: rowie718
4 Replies

10. Shell Programming and Scripting

Script (ksh) to get data in every 30 mins interval for the given date

Hello, Since I m new to shell, I had a hard time to sought out this problem. I have a log file of a utility which tells that batch files are successful with timestamp. Given below is a part of the log file. 2013/03/07 00:13:50 Apache/1.3.29 (Unix) configured -- resuming normal operations... (12 Replies)
Discussion started by: rpm120
12 Replies
AUTOMOUNTD(8)						    BSD System Manager's Manual 					     AUTOMOUNTD(8)

NAME
automountd -- automatic mount / unmount daemon for autofs SYNOPSIS
/usr/libexec/automountd [-v] [-n] [-T] [-o opts] [-D name=value] DESCRIPTION
automountd is a daemon that responds to requests from autofs to mount and unmount network filesystems, and to supply the contents of directo- ries, based on the contents of automounter maps. The automountd is started on demand by launchd(8). As the daemon is launched by launchd, the options below would be specified in the ProgramArguments key in the launchd plist for automountd. See FILES below. OPTIONS
-v Log to syslogd(8) more detailed information about actions taken by automountd. -n Disable browsing of all maps. -T Increase by 1 the logging level for messages printed to the standard output information about requests received from autofs, process- ing done for those requests, and replies sent to autofs. The default level of 0 causes no information to be logged; each higher value causes more information to be logged. -o opts Apply the options specified by opts to all mounts by default. The options for a particular mount can override these options. -D name=value Set the environment value specified by name to the specified value. Environment variables can be referred to in map entries; the value of the environment variable is substituted for the reference to the variable. FILES
/etc/autofs.conf configuration file used to manage automountd /System/Library/LaunchDaemons/com.apple.automountd.plist launchd plist SEE ALSO
auto_master(5), autofsd(8), automount(8), autofs.conf(5), mount(8), mount_nfs(8), launchd(8), launchd.plist(5) Darwin April 4, 2007 Darwin
All times are GMT -4. The time now is 10:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy