LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-02-2005, 11:06 PM   #1
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Rep: Reputation: 45
simple cron question


if i set a crontab -e job to look as follows will it run the service every 30min?

30 * * * * command -cron

???

i hope that is simple. i basically need to run something every 30min, if this is not how it is done, please advise me. i looked here:

http://www.unixgeeks.org/security/ne...ix/cron-1.html

but could not get the */30 * * * to work that gave me an error:

Quote:
Cron also supports 'step' values.
A value of */2 in the dom field would mean the command runs every two days
and likewise, */5 in the hours field would mean the command runs every
5 hours.
e.g.
* 12 10-16/2 * * root backup.sh
is the same as:
* 12 10,12,14,16 * * root backup.sh

*/15 9-17 * * * root connection.test
Will run connection.test every 15 mins between the hours or 9am and 5pm
i was trying to get something like the last line example there to run.
 
Old 03-02-2005, 11:10 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
if i set a crontab -e job to look as follows will it run the service every 30min?

30 * * * * command -cron
No, that would run at 30 minutes past every hour.

*/30 * * * * command -cron This will run every 30 minutes.
 
Old 03-03-2005, 01:02 AM   #3
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
ok, then i must of done something wrong the first time around to get an error.

*/30 * * * * svc -t /service/imapssl -cron

that would reset the imapssl server every 30min is that correct?
 
Old 03-03-2005, 08:17 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
*/30 * * * * svc -t /service/imapssl -cron
That's the correct time setup. I don't know about your command though. I don't seem to have a command called svc on FC3 . Normally, to restart a service I use the command like this...
service smb restart. You do want to use the full path in a cron job so that would look like this..
*/30 * * * * /sbin/service smb restart ## example
 
Old 03-03-2005, 09:55 AM   #5
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
yes that would be true, but IMAPssl is one of those funky servies:

Code:
(root@mail) 1 ~ # svc -t /service/imapssl/
(root@mail) 2 ~ # service imapssl restart
imapssl: unrecognized service
(root@mail) 3 ~ # services imapssl restart
services: Command not found.
(root@mail) 4 ~ # service
Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]
(root@mail) 5 ~ # service imapssl restart
imapssl: unrecognized service
according to this URL about qmail:

http://cr.yp.to/qmail/faq/admin.html the svc -t /service/SERVICE_HERE is the proper way to reset something for qmail like the imapssl server.

why is it that cron is telling me that svc -t does not exsist, yet as you can seei can type it in exactly as i have it in my cron job and it works flawlessly.
 
Old 03-03-2005, 10:35 AM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Cron probably can't find the path to svc. Try to find it with the command: whereis svc
Put the path which it shows in the cron job.
 
Old 03-03-2005, 11:04 AM   #7
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
ok so the full path will be:

Code:
/usr/local/bin/svc -t /service/imapssl
and look like */30 * * * * /usr/local/bin/svc -t /service/imapssl/
 
Old 03-03-2005, 11:05 AM   #8
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
ok that did not work either. just got this error from cron (its set to send me an e-mail every time it has an error
Quote:
svc: warning: unable to chdir to service/imap*: file does not exist
 
Old 03-03-2005, 11:30 AM   #9
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Do a whereis service and use the full path to that also.
 
Old 03-03-2005, 12:33 PM   #10
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
turned out that crontab -e is the user cron job and does not have the same PATH$ as the user does. in my case root.

i had to call someone on my LUG to get help, but the bottom line was he created a sh script that told the cron job were to find the svc -t /service/imapssl and to run that.

after he did that cron liked what it was told as it now had the information for the PATH$ thanks to the script.

thank you for all the help.
 
  


Reply



Posting 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



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple cron job: not working Robert0380 Linux - Software 3 06-24-2008 04:45 AM
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
how to make a simple code for just restarting Apache via a Cron job hsa Programming 1 08-22-2005 04:15 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration