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 > macOS > New to UNIX...Cron question...

New to UNIX...Cron question...
Thread Tools
nigeljedi
Grizzled Veteran
Join Date: Jan 2001
Location: Southwest Missouri
Status: Offline
Reply With Quote
Feb 16, 2002, 01:52 AM
 
Hey, all. I decided recently that I might as well start the learning process associated with UNIX. I know that it's not an overnight thing, but I bought some reading material, and thought I'd start simple with a few cron items.
My question is in regards to making a routine update_prebinding task. I thought I would start by making an entry into crontab that would run the prebinding task once a day (or whatever time period), but I'm not sure about a few things.
First, I can open the crontab just fine with crontab -e, and I'm sure I can figure out how to enter what time I want it to run. Then, I'm assuming, I can run the command sudo update_prebinding -root / to get it working (if any of this is incorrect so far, please let me know). Ok. After that, do I just save that crontab and voila'?
And, once I have entered the command, how do you "properly" quit the crontab?
I appreciate any info you gurus can provide! Thanks!
     
nigeljedi  (op)
Grizzled Veteran
Join Date: Jan 2001
Location: Southwest Missouri
Status: Offline
Reply With Quote
Feb 16, 2002, 01:59 AM
 
Ok. Nevermind on the "how to quit crontab" thing...got that one figured out. Just the actual verbage for the command still needed. Thanks!
     
Camelot
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Feb 16, 2002, 04:00 AM
 
You're almost there in that update_prebinding -root / is the command you want to run, however, you need to enter it in root's crontab rather than putting in in your crontab and using sudo.

The reason for this is that sudo requires a password to be entered at the time the command is executed. Entering in root's crontab will allow it to run as root without any user interaction.

Therefore, to add the command to root's crontab, run sudo crontab -e

Each line in the crontab identifies one command and what time(s) it is to be run.

Each line begins with 5 fields that determine the frequency followed by the command itself.

The time fields, in order, are:

minute
hour
day of month
month
day of week

Any of the fields can be set to *, which means all.

Therefore, * * * * * means run every minute of every hour of every day of every month, whereas 5 * * * * runs at 5 minutes past every hour.

You can also combine multiple values for any unit, for example:

0,15,30,45 * * * * will run the command every 15 minutes

* 0,12 * * * runs at noon and midnight every day

0 0 1 * * runs at midnight on the first day of every month

etc., etc. (man 5 crontab will give you more info on setting the time intervals)

So, knowing how the time fields work your solution is:

sudo crontab -e

0 0 * * * update_prebinding -root /

(and save your crontab)

This will run update_prebinding every day at midnight. Feel free to change the time interval as you see fit - if you think daily is too frequent, change the 'day of week' interval to run on certain days - 0 1 * * 1 will run at 1am every Monday
Gods don't kill people - people with Gods kill people.
     
nigeljedi  (op)
Grizzled Veteran
Join Date: Jan 2001
Location: Southwest Missouri
Status: Offline
Reply With Quote
Feb 16, 2002, 10:41 PM
 
Thanks a million! I forgot that when typing sudo, it asks for a password...
     
nigeljedi  (op)
Grizzled Veteran
Join Date: Jan 2001
Location: Southwest Missouri
Status: Offline
Reply With Quote
Feb 16, 2002, 11:14 PM
 
Well, I'm at an impasse' with this. I've used the sudo crontab -e command to begin to enter the prebinding request. The following picture shows it:

The problem is that I can't exit the vi editor. When I enter :q or any other actual command, it just acts as if it were accepting more lines of text. Once the prebinding text is entered, how do I save and exit if Terminal won't accept commands?
(Is this clear as mud?)

[ 02-16-2002: Message edited by: nigeljedi ]
     
rantweasel
Dedicated MacNNer
Join Date: Oct 2001
Location: Philly
Status: Offline
Reply With Quote
Feb 18, 2002, 07:36 PM
 
Originally posted by nigeljedi:
<STRONG>
The problem is that I can't exit the vi editor. When I enter :q or any other actual command, it just acts as if it were accepting more lines of text. Once the prebinding text is entered, how do I save and exit if Terminal won't accept commands?
(Is this clear as mud?)
</STRONG>
Um, are you forgetting to use ESC to switch back from insert mode to command mode? Invariably the source of all of my own vi problems...
     
becca
Junior Member
Join Date: Jul 2001
Location: Nashville Tn.
Status: Offline
Reply With Quote
Feb 18, 2002, 11:01 PM
 
Try :wq to write the file or just ZZ
Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety.
Benjamin Franklin, Historical Review of Pennsylvania, 1759
     
nigeljedi  (op)
Grizzled Veteran
Join Date: Jan 2001
Location: Southwest Missouri
Status: Offline
Reply With Quote
Feb 18, 2002, 11:56 PM
 
Thanks a bunch! That worked. I guess in my haste, I didn't ever press esc...or didn't recognize that it changed from insert to command...

But, it seems to have worked. I'll just have to wait until midnight to see if it starts the process. I can check the sudo crontab -e, however, and see the entry still there...
Thanks again! Now, off to learn more UNIX!


[ 02-18-2002: Message edited by: nigeljedi ]
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 10:45 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,