How can I make this happen during user' login?

TechSpecialist
Contributor
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 2

dsavageED
Contributor III

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
Valued Contributor

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