Logging to server via bash script

user-iqIeyixQkS
New Contributor

I thought I had already posted this, but it's no where to be found. I use a bash script which kills Zoom Rooms and forces a restart. Unfortunately this script doesn't leave any evidence of running, likely because it restarts before the script actually finishes. Is there a way to get Jamf to write to any server log via a command, such as the 3rd line below.

```

! /bin/zsh

killall ZoomPresence
jamf writelogentry
shutdown -r now
exit 0```

2 REPLIES 2

PaulHazelden
Valued Contributor

You could echo to a local file, as a log. and then use an EA script to look for the existence of the file. Then run a Smart group based on the EA. This will find them, and add them to a group, but it is not an instant thing. The EA has to report to the server, and then the results will add the computer to the group. And it will only tell you the script has run, not how many times.

AJPinto
Honored Contributor II

There is no way to do this baked in to JAMF. I really wish JAMF did logging both when a policy starts and when one finishes. Since JAMF only logs at policy completion many policies that force reboots dont drop logs if done in a certain way. 

 

As @PaulHazelden suggested just add a function to your script before the reboot to drop a log file and use JAMF to read for that log file with an extension attribute. If you want to get really fancy you can create a launch agents and daemons with your script and have the log dropped when the Mac comes back up.