Issue Running Script

ts85
New Contributor III

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
7 REPLIES 7

alexjdale
Valued Contributor III

What are you grepping after the pipe in the first command, and why?

davidacland
Honored Contributor II

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/*

ts85
New Contributor III

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?

mm2270
Legendary Contributor III

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.

davidacland
Honored Contributor II

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.

kitzy
Contributor III

@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!

ts85
New Contributor III

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!