Skip to main content
Question

How can I make this happen during user' login?

  • February 11, 2020
  • 2 replies
  • 1 view

Forum|alt.badge.img+8
rm -rf /Users/$3/Desktop/*
rm -rf /Users/$3/Downloads/*
rm -rf /Users/$3/Documents/*

I've enabled the login/logout hooks in JSS
I've enabled the "Perform login hook actions in background"
I've scoped the policy with a trigger for logging in.

If I make this available in Self Service, it works flawlessly, but I need this to be automated during the user's login.

2 replies

dsavageED
Forum|alt.badge.img+8
  • New Contributor
  • February 11, 2020

I think you would need to define the username in the context of the script, certainly our login scripts if they need the user, run code rather than use the jamf variable. Something like:

consoleUser=$(ls -l /dev/console | awk '{ print $3 }')
rm -rf /Users/${consoleUser}/Desktop/*

PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • February 11, 2020

Apples recommended method would be to make a script and then use a LaunchAgent to launch the script at user login.