Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Making CRON run every x minutes using "/x"

Making CRON run every x minutes using "/x"
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Jun 24, 2005, 01:28 PM
 
I'm running an OS X machine as a file server for several people in an office. There's a folder we use as a "common" area, where we want one user to be able to stick a file and have another modify it. The problem is that by default, OS X sets permissions of such files as writable by owner only. To get around that, I came up with the following for my crontab file:

0 * * * * echo password | sudo chmod -R 777 /ThatFolder/* > /dev/null

so that every hour, it'd fix the permissions on all files/folders within ThatFolder, and silence sudo's password prompt. Worked like a charm. But it wasn't triggering fast enough for users, so I decided to have it trigger every 10 minutes or so, did a little Google research, and came up with:

*/10 * * * * echo password | sudo chmod -R 777 /ThatFolder/* > /dev/null

It seemed to work. But next time I checked the admin's email, there was a flood of cron messages that just said "Password:", every 10 minutes. I tried changing the 10 to a 2, and that shut it up. 3 and 4 also worked fine. But setting it to */5 (or 0-59/5, makes no difference) or higher generates emails again.

I'm completely baffled. Anyone have any ideas?
     
Mac Enthusiast
Join Date: May 2001
Status: Offline
Reply With Quote
Jun 24, 2005, 01:54 PM
 
Are you using server or client? What version?
All opinions are entirely those of my employer. It's not my fault.
     
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Jun 24, 2005, 02:10 PM
 
Whoops, sorry. Running 10.3.9 client, if that makes any difference.
     
Fresh-Faced Recruit
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jun 27, 2005, 02:49 PM
 
I think you are running into a couple differnet things. The reason it doesn't work over 5 minutes is that your sudo time period runs out and requires you to reauthenticate. I don't believe your command will actually work and that is why it asks for the password but when you run it under 5 minutes it resets the timeout period.

What you want to do is change your sudo command to include the -S option which tells it to read the password from stdin. This will work with the echo:

echo password | sudo -S cmd

Another option is to put the command in the root crontab if you want and then it will have the permissions. You can do this by calling 'sudo -s' and then setting the cronfile. You might want to be careful not to overwrite anything with this but you won't have to store your password in the cronfile.

Hope this helps.
     
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status: Offline
Reply With Quote
Jun 27, 2005, 02:53 PM
 
I would suggest Cronnix. It might be able to help you simplify the situation. If not you can always email the support (it's free)

http://www.abstracture.de/projects-en/cronnix/
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:22 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2