Posted on 09-16-2015 02:02 PM
Hello,
I want to run some maintenance on our edit stations using Premiere, so I wrote a script that looks for all users in /Users and clears the ~/Library/Application Support/Adobe/Common/Media Cache Files/*
The script runs fine if I copy to the station and run ./cleanAdobeMediaCache, however when I added the script and created the policy it will not find the directory or any users. All stations have User accounts and since all are using Premiere have the Media Cache Folder. What am I missing?
#!/bin/sh
users=`find /Users -type d -maxdepth 1 -mindepth 1 ! -name Shared ! -name admin ! -name guest | grep "$a"`
for i in $users; do
if [ -d "$i/Library/Application Support/Adobe/Common/Media Cache Files/" ]; then
rm -rf $i/Library/Application Support/Adobe/Common/Media Cache Files/*
fi
done
exit 0
Posted on 09-16-2015 02:06 PM
What are you grepping after the pipe in the first command, and why?
Posted on 09-16-2015 02:12 PM
It looks ok to me, so I would add a bit more output to the script using echo and $?:
#!/bin/sh
users=`find /Users -type d -maxdepth 1 -mindepth 1 ! -name Shared ! -name admin ! -name guest | grep "$a"`
echo $users # display the contents of the variable for verification
for i in $users; do
if [ -d "$i/Library/Application Support/Adobe/Common/Media Cache Files/" ]; then
rm -rf $i/Library/Application Support/Adobe/Common/Media Cache Files/*
echo $?
fi
done
exit 0
The other alternative is to use the files and processes part of a Casper policy:
rm -rf /Users/$3/Library/Application Support/Adobe/Common/Media Cache Files/*
Posted on 09-16-2015 02:23 PM
Thanks for the quick reply, I had echo'd out the variable but I'm not sure where to view that when running from either Self-Service or Remote?
--
On a side note with the Casper Policy option you also suggested, where would '$3' be populated?
Posted on 09-16-2015 02:25 PM
I have the same question as @alexjdale What is the grep "$a"
supposed to be grabbing? I don't see a reference in your script to a variable labeled as "a" so I don't see how that's actually doing anything.
Posted on 09-16-2015 02:28 PM
If it's run in self service you can see the output of the echo commands in the policy log on the JSS.
$3 would be if the policy ran at login so not so useful in this case.
Posted on 09-16-2015 02:33 PM
@drew.diver I think you just need to drop
"| grep $a"
From your find command. The line should look like this:
users=`find /Users -type d -maxdepth 1 -mindepth 1 ! -name Shared ! -name admin ! -name guest`
Hope that helps!
Posted on 09-16-2015 02:41 PM
That did it, I wasn't sure on the "| grep $a" either. I constructed this command from another area in the JAMF forum the other day. He also didn't have any other reference to "$a" but it was pulling what I needed so I left it.
Thanks for the input!