LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-09-2006, 04:35 AM   #1
Thulemanden
Member
 
Registered: Sep 2003
Location: Copenhagen, Denmark
Distribution: PC-BSD, PCLOS, MeeGo, Win 7
Posts: 189

Rep: Reputation: 30
crontab job


Will it work saving a file named 'crontab' using any text editor with the content

1 * * * * webalizer

in path /var/spool/cron/crontabs/

I want webalizer to run every hour a minute 1

Will it produce too many log lines?

Will

* 17 * * * webalizer

run it a 17:00 hrs each day?

I use this as source:
http://www.adminschoice.com/docs/crontab.htm

Last edited by Thulemanden; 07-09-2006 at 04:38 AM.
 
Old 07-09-2006, 05:11 AM   #2
trev_vb
LQ Newbie
 
Registered: Jul 2006
Location: In a house
Distribution: You mean there's MORE than one? I better let Mr. Gates know
Posts: 4

Rep: Reputation: 0
In answer to question #1 ("Will it work saving ...)
The best answer I can give is "Probably not, and even if it does wok, it might not give you _exactly_ what you EXPECTED".

Your login tag states that you're using Xandros (and this is, afterall, the slackware forum). Having said that, you're _probably_ using the same cron we all use.
Technically speaking, the _correct_ way to install a cron job is to use the crontab(1) command. (I would stronly urge you to do a "man crontab" sometime soon and read it).

Basically, cron is a process that schedules tasks to run at specific times. Perhaps most importantly of all though is that cron _ALSO_ specifies which user-id the task runs as and thus the scheduled task will 'inherit' all the permissions / capabilities of that nominated user.

By manually creating a file as /var/sppol/cron/crontabs/crontab (that _is_ what you were stating afterall), then you're creating an entry in the task schedule to run the task using the permissions / capabilities of a user named "crontab" (that being the name of the file in question). If you don't _have_ a user named "crontab" on your system, then your results will be at best unpredictable, and at worst, no results at all other than a line in your system error log.

If you created the file in your home directory instead (let's say you called it 'cron.job' and then submitted it to the cron scheduler with the command:
crontab cron.job
It would create the relevant file for you in /var/spool/cron/crontabs (naming it using YOUR login name, and giving the file relevant permissions).
This job would run the program named 'webalizer' at 1 minute past the hour on EVERY hour of EVERY day and the program would inherint *YOUR* login credentials.

Now here's a few potential 'gotchas' that you should be aware of
1: Since you've not specified a FULL pathname to the application to be run, cron will search through its $PATH hierarchy and run the first one it finds. Thus, it becomes potentially 'easier' for some a$$hole to create a 'rogue' program in a directory that is higher up in your path hierarchy and cron will dutifully run HIS / HER program instead of yours. (Therefore, I would suggest you might want to fully path the application to run from the cron job).
2: I'm guessing that webalizer is a process to extract summary data from your webserver, I am surmizing that *YOUR* login probably doesn't have the necessary permissions to access the relevant log files in order for webalizer to run. (Or at least I *HOPE* your doesn't?... You don't login as root do you?) Therefore, you might wish to have this cron job submitted to the scheduler as some OTHER username [RTFM on crontab as mentioned above, specifically the "-u" switch]. I'd try to AVOID running the job as root unless you ABSOLUTELY HAVE TO (due to the implicit security considerations). The user that the web service itself runs as should be ideal for the job.

Now, to your 2nd question... (re running a job at 17:00 hrs each day)
The sample you've given would run the task at 17:00, then again at 17:01, then again at 17:02 (etc etc) until 17:59 (i.e. 60 times in total)
What you probably _WANT_ instead is something like this:
0 17 * * * webalizer
The explicit coding of 0 for minutes means it runs ONLY at 17:00 (and not the other 59 minutes). The process is started once per day every day (and it will run for as long as it takes, so if it is still running at 17:01, don't be worried)

HTH,

TvB
 
Old 07-09-2006, 06:57 AM   #3
Thulemanden
Member
 
Registered: Sep 2003
Location: Copenhagen, Denmark
Distribution: PC-BSD, PCLOS, MeeGo, Win 7
Posts: 189

Original Poster
Rep: Reputation: 30
Thank you very much.

I have included the path and put in the zero, saved the file as crontab.job and run 'crontab crontab.job'

That was the easy part. I'll look at the user issue.

Actually, the labtop web server is running DSL with Firestarter.
I'm writing from my main PC carrying PC-BSD :-)

A Windows XP is seldom turned on any longer. :-)))

Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run crontab job every 30 seconds houssamfarag Slackware 5 06-23-2006 02:45 AM
how to run crontab job every 20 seconds houssamfarag Mandriva 4 06-23-2006 02:45 AM
crontab job entry notolerance Linux - Software 2 02-20-2005 02:40 PM
Can I get a konsole to start from a crontab job? davee Linux - Newbie 2 03-05-2004 05:22 AM
crontab job to restart tomcat... barbean Programming 0 11-17-2003 12:58 AM


All times are GMT -5. The time now is 05:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration