Skip to main content
Question

Launchdaemon run script issues


_aDiedericks
Forum|alt.badge.img+8

Hi there,

I have a script that runs once on each machine in our macOS fleet. The script essentially creates a launchdaemon that runs a script that kills and restarts jamf binaries on machines once a day to mitigate the jamf checkin issues (no we do not have a force restart schedule).

Issue I'm noticing is that some devices (about 50) even though they have the launchdaemon loaded it doesn't seem to be restarting their Jamf binaries. My thinking is it may be the script that is not working as intended.

I intend for the restart script to be re-ran everyday on the local machine but some devices have not checked in for weeks now.

 

#!/bin/sh cat << 'EOF' > /private/var/tmp/JamfRestart.sh #!/bin/sh sudo killall jamf sleep 10 sudo jamf policy EOF chmod 755 /private/var/tmp/JamfRestart.sh chown root:wheel /private/var/tmp/JamfRestart.sh cat << EOF > /Library/LaunchDaemons/com.JamfRestart.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>EnvironmentVariables</key> <dict> <key>PATH</key> <string>/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/sbin:/opt/local/bin</string> </dict> <key>Label</key> <string>JamfRestart</string> <key>ProgramArguments</key> <array> <string>/bin/sh</string> <string>/private/var/tmp/JamfRestart.sh</string> </array> <key>RunAtLoad</key> <false/> <key>StartInterval</key> <integer>86400</integer> </dict> </plist> EOF chmod 644 /Library/LaunchDaemons/com.JamfRestart.plist chown root:wheel /Library/LaunchDaemons/com.JamfRestart.plist launchctl load -w /Library/LaunchDaemons/com.JamfRestart.plist

 

 

6 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • May 3, 2024

@_aDiedericks You really don't want to put scripts you need to be on the Mac long term in /private//var/tmp. A better location would be something like "/Library/Management/MyOrgName" or "Library/Application Support/MyOrgName"


_aDiedericks
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 48 replies
  • May 3, 2024
sdagley wrote:

@_aDiedericks You really don't want to put scripts you need to be on the Mac long term in /private//var/tmp. A better location would be something like "/Library/Management/MyOrgName" or "Library/Application Support/MyOrgName"


Thanks, I'll onboard this info on my end and make the adjustments. Do you know how I can log the output of the script's last run? Referring to within the "JamfRestart.sh" script.


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3536 replies
  • May 3, 2024
_aDiedericks wrote:

Thanks, I'll onboard this info on my end and make the adjustments. Do you know how I can log the output of the script's last run? Referring to within the "JamfRestart.sh" script.


You'd need to put code into your script that would write to a file in /var/log. Here's a useful example of that: https://community.jamf.com/t5/jamf-pro/script-log-to-text-file/m-p/137935/highlight/true#M127017

 


jamf-42
Forum|alt.badge.img+17
  • Esteemed Contributor
  • 741 replies
  • May 3, 2024

JAMF Checkin issue? is there a PI for this? Anyone else seeing this? 


_aDiedericks
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 48 replies
  • May 7, 2024
sdagley wrote:

You'd need to put code into your script that would write to a file in /var/log. Here's a useful example of that: https://community.jamf.com/t5/jamf-pro/script-log-to-text-file/m-p/137935/highlight/true#M127017

 


Thanks. Got the log working.


_aDiedericks
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 48 replies
  • May 7, 2024
jamf-42 wrote:

JAMF Checkin issue? is there a PI for this? Anyone else seeing this? 


It's not a general issue. Some people have it, some dont. I think it's due to a policy/script running during jamf policy update on devices that doesn't exit or complete that causes jamf binaries to hang indefinitely until the process is killed or device is restarted.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings