LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   newbie needing help creating a cron job (https://www.linuxquestions.org/questions/linux-software-2/newbie-needing-help-creating-a-cron-job-264744/)

Lleb_KCir 12-10-2004 01:29 AM

newbie needing help creating a cron job
 
Code:


# which svc
/usr/local/bin/svc
# cat > /etc/cron.d/restart-imap
3 0-23/2 * * *{TAB}/usr/local/bin/svc -t /service/imap*
^D

ok i want to turn that into a cron job, but i have not the fogiest clue when it comes to coding or even were or how to save something like this.

*note* when it states {TAB} that is to hit the tab key

i got this off a site that should help me resolve one of the hickups my whitebox q-mail server is having with IMAP.

A. what path do i save the file in once it is created?
B. what extention and file name format do i give it so cron knows what to do.

yes i read man cron, but it confused the daylights out of me. from what little i could gather it gets its info from /etc/init.d, but that is just a list of services, nothing i can edit to add the above code.

help...

thanks.

hob 12-10-2004 07:04 AM

Red Hat has a easy option for this - every script file in /etc/cron.hourly will be executed every hour.

I don't know if Debian has this. If not then you use:

crontab -e

This will open the crontab file for the user in the default text editor and you can save the changes in the normal way when done.

/etc/init.d is for service scripts. Crontab files live in a subdirectory of /var, but you should use the crontab command rather than poke them directly.

Emerson 12-10-2004 07:46 AM

Tip!
 
Use full path in the crontab, even if the executable you want to run is on your path. Like this:

/usr/bin/my_coffee_maker

Lleb_KCir 12-10-2004 11:27 AM

thanks for trying. i just so do not get this cron stuff... when i did the crontab -e it was a blank file, now i know that is not correct, and when i whereis crontab i found it /usr/bin/crontab and used vim to open it into a bunch of what looks like junk on the screen indicating to me that it is not in a text format to be edited in a normal fassion.

*hangs head* so lost, but someday ill figure this stuff out.

hob 12-11-2004 03:23 AM

The file in /usr/bin is the crontab program, which is managed by the service script in /etc/init.d.

Every minute cron is run and checks the crontab files for each user in /var/spool/cron. A user creates or edits their crontab file with 'crontab -e', and the instructions inside are run with that user's account. So to set up system tasks you will often want to do 'crontab -e' as root. The crontab file is empty to start with, and you can put the stuff you listed in the first post in it.

Red Hat systems will also run the scripts in /etc/cron.d/hourly, /etc/cron.d/daily and /etc/cron.d/weekly, as well as the crontab files for the users.

Lleb_KCir 12-13-2004 03:58 PM

thanks.


All times are GMT -5. The time now is 10:14 PM.