Skip to main content
Question

The Nudge Launch Agent Do not open

  • August 1, 2022
  • 30 replies
  • 339 views

Show first post

30 replies

TechGuy77
Forum|alt.badge.img+1
  • New Contributor
  • May 3, 2023

Hi @bwoods ,
The result of your script shows me this error, any idea ?

Running script Create com.github.macadmins.Nudge.plist... Script exit code: 0 Script result: Nudge launch agent is not present. /Library/Application Support/JAMF/tmp/Create com.github.macadmins.Nudge.plist: line 20: /Users/myuser/Library/LaunchAgents/com.github.macadmins.Nudge.plist: No such file or directory /Users/myuser/Library/LaunchAgents/com.github.macadmins.Nudge.plist: No such file or directory Load failed: 2: No such file or directory

Actually, in this instance, this means the LaunchAgents directory does not exist so it can't create the LaunchAgent file. I made an edit to fix this as I think it's an issue with newer MacOS version like Ventura as those directories don't exist for users by default anymore. Here is the script with my edit to make the directory needed before the echo.

 

#!/bin/bash # Determine Current User currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) # Determine Current User ID currentUserUID=`id -u "$currentUser"` # Verifies Presence of Nudge Launch Agent if [[ -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is present" /bin/launchctl asuser "$currentUserUID" launchctl unload /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist rm -Rf /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist elif [[ ! -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is not present." fi mkdir "/Users/$currentUser/Library/LaunchAgents/" # Generate Nudge launch agent echo "<?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>Label</key> <string>com.github.macadmins.Nudge</string> <key>ProgramArguments</key> <array> <string>/Applications/Utilities/Nudge.app/Contents/MacOS/Nudge</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>" > /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist # Load Launch Agent /bin/launchctl asuser "$currentUserUID" launchctl load /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist exit 0 ## Success exit 1 ## Failure

 

  


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • May 4, 2023

Actually, in this instance, this means the LaunchAgents directory does not exist so it can't create the LaunchAgent file. I made an edit to fix this as I think it's an issue with newer MacOS version like Ventura as those directories don't exist for users by default anymore. Here is the script with my edit to make the directory needed before the echo.

 

#!/bin/bash # Determine Current User currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) # Determine Current User ID currentUserUID=`id -u "$currentUser"` # Verifies Presence of Nudge Launch Agent if [[ -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is present" /bin/launchctl asuser "$currentUserUID" launchctl unload /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist rm -Rf /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist elif [[ ! -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is not present." fi mkdir "/Users/$currentUser/Library/LaunchAgents/" # Generate Nudge launch agent echo "<?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>Label</key> <string>com.github.macadmins.Nudge</string> <key>ProgramArguments</key> <array> <string>/Applications/Utilities/Nudge.app/Contents/MacOS/Nudge</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>" > /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist # Load Launch Agent /bin/launchctl asuser "$currentUserUID" launchctl load /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist exit 0 ## Success exit 1 ## Failure

 

  


Good catch, that folder exists on all of my clients because of Onedrive. May not be the case for everyone else.


Forum|alt.badge.img+5
  • Contributor
  • May 15, 2023

Example of 4 hours

#!/bin/bash # Determine Current User currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) # Determine Current User ID currentUserUID=`id -u "$currentUser"` # Verifies Presence of Nudge Launch Agent if [[ -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is present" /bin/launchctl asuser "$currentUserUID" launchctl unload /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist rm -Rf /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist elif [[ ! -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is not present." fi # Generate Nudge launch agent echo "<?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>Label</key> <string>com.github.macadmins.Nudge</string> <key>ProgramArguments</key> <array> <string>/Applications/Utilities/Nudge.app/Contents/MacOS/Nudge</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>14400</integer> </dict> </plist>" > /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist # Load Launch Agent /bin/launchctl asuser "$currentUserUID" launchctl load /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist exit 0 ## Success exit 1 ## Failure

I pushed the launch agent that is part of the nudge suit package on GitHub. Will this script overwrite and/or stop that default agent and use your script instead? 


Forum|alt.badge.img+1
  • New Contributor
  • February 6, 2024

Actually, in this instance, this means the LaunchAgents directory does not exist so it can't create the LaunchAgent file. I made an edit to fix this as I think it's an issue with newer MacOS version like Ventura as those directories don't exist for users by default anymore. Here is the script with my edit to make the directory needed before the echo.

 

#!/bin/bash # Determine Current User currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) # Determine Current User ID currentUserUID=`id -u "$currentUser"` # Verifies Presence of Nudge Launch Agent if [[ -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is present" /bin/launchctl asuser "$currentUserUID" launchctl unload /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist rm -Rf /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist elif [[ ! -f /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist ]]; then echo "Nudge launch agent is not present." fi mkdir "/Users/$currentUser/Library/LaunchAgents/" # Generate Nudge launch agent echo "<?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>Label</key> <string>com.github.macadmins.Nudge</string> <key>ProgramArguments</key> <array> <string>/Applications/Utilities/Nudge.app/Contents/MacOS/Nudge</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>" > /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist # Load Launch Agent /bin/launchctl asuser "$currentUserUID" launchctl load /Users/$currentUser/Library/LaunchAgents/com.github.macadmins.Nudge.plist exit 0 ## Success exit 1 ## Failure

 

  


Thanks for this! Worked great on the majority of devices but I have a few outliers that error out. I get the "/Library/LaunchAgents/com.github.macadmins.Nudge.plist: No such file or directory" but instead of creating the plist I get "Load Failed: 5: Input/output error" Any ideas?


cucaracha
Forum|alt.badge.img+5
  • Contributor
  • May 26, 2024

Thanks for this! Worked great on the majority of devices but I have a few outliers that error out. I get the "/Library/LaunchAgents/com.github.macadmins.Nudge.plist: No such file or directory" but instead of creating the plist I get "Load Failed: 5: Input/output error" Any ideas?


Probably need to run a pre-script to bootout the LaunchAgent if it's already running.

#!/bin/bash #Preinstall Script #Daemon Preinstall plistPath="/Library/LaunchAgents/com.github.macadmins.Nudge.plist" #Boot it out if it already exists if [[ -e $plistPath ]]; then launchctl bootout system $plistPath rm -f $plistPath fi