Posted on 01-27-2012 04:28 AM
I would like to shut down a machine after a policy triggered by logout has completed.
Casper offers the "Reboot" option, but no shutdown.
If I append a shutdown -h now command to the policy,
there is no Log written to the JSS because the client goes down straight away.
Currently I see two ways to get around this:
First, shutdown -h +1 instead of now - not that elegant
Second, make two policies, one containing the actual commands, with a custom trigger,
the other one triggering the first policy and shutting down afterwards - two policies for one job, don't like that either ;)
Any of you geniuses with a hint for me?
Posted on 01-27-2012 06:59 AM
I haven't tested this to see if it will write to the JSS but you can add an ampersand to the end of a line to put the process into the background:
shutdown -h +10 &
That allows the rest of the script to proceed in parallel and may give the machine a chance to complete reporting to the JSS.
Posted on 02-09-2012 02:13 AM
Hi Chris
I've created this script for the task of logging to jamf.log
Upload to Casper and run it after your policy.
Let me know if helps.
Regards
Mauricio
###############
#!/usr/bin/perl
$pathToScript=$0;
$pathToPackage=$ARGV[0];
$targetLocation=$ARGV[1];
$targetVolume=$ARGV[2];
# format day and time as per jamf log.
$DATE= localtime(time);
@DATE =split (' ',$DATE);
$DATE=$DATE[0]." ".$DATE[1]." ".$DATE[2]." ".$DATE[3];
$log="/var/log/jamf.log";
open(LOG, ">>$log") || die "Can't open log file: $!
";
# Entry to jamf.log
print LOG "$DATE This mac is shutting down now....
";
close (REPORT);
# shut down command.
$command="shutdown -h now";
`$command`;
exit 0; ## Success
exit 1; ## Failure