QUOTE (Lama @ Aug 21 2008, 09:50 AM)

<br /><img src="style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> I would be so happy if he never goes on holidays...<img src="style_emoticons/default/weight_lift.gif" style="vertical-align:middle" emoid=":weight_lift:" border="0" alt="weight_lift.gif" /> I know I'm cruel, guess "thats only me" <img src="style_emoticons/default/dev.gif" style="vertical-align:middle" emoid=":dev:" border="0" alt="dev.gif" /><br /><br /><br /><br />How to use this script? Copy paste in TextEdit and save as something.??? and where??? What to change for '2' minutes to 'xx' minutes? If this is fully automated, it belongs in my first post <img src="style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> You must assume I'm not very mac geeky (yet) <img src="style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /><br />
It is a cron job which is a way of tell the system you want a certain process/procedure to be run at a specific time interval in this case every two minutes this is the */2 at the start in the minutes position of the line below.
CODE
*/2 * * * * /Users/username/refresh_sb.sh
The the second part of it the /Users.... tells the system what to do/execute this can be a command or again in this case a script, to run every five minutes you can use this.
CODE
*/5 * * * * /Users/username/refresh_sb.sh
The other * in their represent hours, days, weeks, months respectively so you can setup jobs to run virtually any time you want I would suggest Googling on "Using the crontab" for more information on these.
Now to set this up you would need to open the Terminal application then use
sudo -s then type in your password you set on install once you see the
bash-3.2# prompt you know you are root and can type in then hit ENTER key
crontab -e to enter a new cron job the file should be empty at the start. The Mac use of the INSERT key seems to be useless for entering edit mode in vim so hit the
a key (which on my system seems to replace it) and you should see INSERT at the bottom of the page now you can type in the line above. Now you need to save the file so you would hit the ESC key to take you out of insert mode thus you should see the INSERT at the bottom of the file disappear to save the new job you need to type in the hit ENTER key
:wq it should now tell you the new cron is installed like below.
CODE
bash-3.2# crontab -e
crontab: no crontab for root - using an empty one
crontab: installing new crontab
If you had an error you will see something like.
CODE
bash-3.2# crontab -e
crontab: no crontab for root - using an empty one
crontab: installing new crontab
"/tmp/crontab.9dm9QdXrwt":1: bad minute
crontab: errors in crontab file, can't install
Do you want to retry the same edit?
You of course would want to type in
y then hit the enter key to edit the entry to correct it. Before having edited the crontab you would want the script to be in place you can do as above in the second part of the post and use cat to create the file by copy'n'pasting each line into the Terminal window then hitting ENTER key once the last line is entered then use the
CTRL + c keys at the same time to halt the catting of input to the file or by simply opening a text editor and putting each line into it so it would look like the below.
CODE
#!/bin/sh
/sbin/kextunload /System/Library/Extensions/kXAudioDriver.kext 2>&1 > /dev/null
[ $? -ne 0 ] && /sbin/kextunload /System/Library/Extensions/kXAudioDriver.kext 2>&1 > /dev/null
[ $? -ne 0 ] && /sbin/kextunload /System/Library/Extensions/kXAudioDriver.kext 2>&1 > /dev/null
[ $? -ne 0 ] && /sbin/kextunload /System/Library/Extensions/kXAudioDriver.kext 2>&1 > /dev/null
/sbin/kextload /System/Library/Extensions/kXAudioDriver.kext 2>&1 > /dev/null
The first line tells the system to use the sh shell the second tries to unload the .kext then the next three re-tries the command if there was an error doing so the last actually loads the .kext again after removal. Now you would want the script to be executable so you would do with this example file here.
CODE
chmod +x /Users/username/refresh_sb.sh
Since username is not likely to be your login name you need to change this in my case I would use if setting this up.
CODE
chmod +x /Users/MacUser2525/refresh_sb.sh
For this file in my home directory I would suggest not cluttering it up with file in its root directory so would have created a Bin directory for this purpose.
CODE
mkdir /Users/MacUser2525/Bin
As my normal user before using the
sudo -s I mentioned farther up so the command to make executable would become.
CODE
chmod +x /Users/MacUser2525/Bin/refresh_sb.sh
You would use your login name in the commands I list here, hopefully I have explained this enough so you can understand the procedure involved.