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
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
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
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
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
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)
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
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
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
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
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
LEARN ABOUT OSX
taskgated
taskgated(8) BSD System Manager's Manual taskgated(8)
NAME
taskgated -- task_for_pid access control daemon
SYNOPSIS
taskgated [-ps] [-t timeout] [-i pid]
DESCRIPTION
taskgated is a system daemon that implements a policy for the task_for_pid system service. When the kernel is asked for the task port of a
process, and preliminary access control checks pass, it invokes this daemon (via launchd) to make the decision.
OPTIONS
-p Accepts the old (Tiger) convention that a process with a primary effective group of procmod or procview is allowed to get task
ports. Without this option, this legacy mode is not supported.
-s Allow signed applications marked as "safe" to have free access to task ports, without having to pass an authorization check. Note
that such callers must be marked both allowed and safe.
-t timeout
The daemon will quit after that many seconds of inactivity. It will be relaunched by launchd as needed. A timeout of zero can be
specified to make the daemon quit after servicing each request, but a small positive timeout is better for performance.
-i pid Inject the service port of taskgated into the process with the given pid, rather than relying on launchd to install it system-wide.
This is for testing only, and requires the launchd configuration for taskgated to be removed.
AUTHORIZATION RIGHTS
system.privilege.taskport Authorization right used to check access of allowed (but not safe) callers.
INFO KEYS
SecTaskAccess A value of "allowed" is required for any program that wants access to task ports. A value of "safe" bypasses authorization
checks if so configured. Code must be signed by any system-trusted signing authority.
FILES
/etc/authorization to configure the authorization used.
/System/Library/LaunchDaemons/com.apple.taskgated
startup configuration file for taskgated
SEE ALSO
security(1), launchd(8)
HISTORY
taskgated was first introduced in Mac OS 10.5 (Leopard).
Certain software updates of Mac OS 10.4 (Tiger) introduced the convention requiring membership in the procmod or procview groups to control
task port access. Before that, any process could obtain the task port of any other process with the same user-id.
Darwin May 31, 2019 Darwin