LinuxQuestions.org
Help answer threads with 0 replies.
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 12-26-2004, 07:35 PM   #1
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
creating a cron(tab) scheduled thing


Hey,

I've already searched the Tutorials, and this forum for a thread on this, but haven't found one. How do you add a thing (I don't know what to call it) to cron so that I can specify it to run a program at 2AM, AND how to terminate it at 9AM. I know you can use ulimit to specify the amount of time a process can run from that terminal, but I'd like it to run without my having to tell it to (thus cron). man cron and man crontab don't say much...

Thanks
 
Old 12-26-2004, 08:06 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Interesting. Probably an elegant way to do it, but couldn't you just schedule it to run at 2 and schedule it to be killed at 9?
* 2 * * * foo
* 9 * * * killall foo

Might help to say which command you want to run.
 
Old 12-26-2004, 08:40 PM   #3
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Original Poster
Rep: Reputation: 34
I want to run the foldingathome.exe (don't worry, it works somehow - it's the "official linux" client) file in the directory /home/alex/folding@home/ simply using dot-slash (./) to run it. But i have to be IN that directory to run it, otherwise because it needs to load the configuration files... and.. somehow it doesn't do it when you type the full path from another directory. This program is completely command-line based and does not require root priviledges. I was thinking I could write a *simple* script to run it; one that just cd's into the folder and runs it.

The thing is, I've never used cron/crontab before ... all i know is that it is like a scheduler that performs actions at certain times and/or intervals.

Oh, and it (foldingathome.exe) doesn't have the luxury of so many options in it's configuration file to let it run at a certain time, and stop later.
Code:
[alex@localhost alex]$ cat folding@home/client.cfg
[settings]
username=amerritt
team=11534
asknet=no
machineid=1
local=1

[http]
active=no
host=localhost
port=8080

[alex@localhost alex]$
That's it.

Is cron difficult to implement?

Last edited by student04; 12-26-2004 at 08:45 PM.
 
Old 12-26-2004, 08:49 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Ah. I see. Sort of.

Yeah - do a 'crontab -e' and you edit the file and schedule programs. Not familiar with folding@home (in the sense of never having used it) but it's strange it would have to be run from a particular directory. Some programs look for configs in particular places, but usually have a command line option to tell them to look in alternate locations. You can schedule scripts to be run, so I suppose you could write a one-liner about 'cd /to/dir && folding@home' or something. Makes sense why you'd want to start and stop it at particular times, though. I don't think a 'killall' would present a problem. A last thing to check is whether the program can sort of schedule itself. Be a nice feature to have if it doesn't.

-- Oops. I was answering before your edit. That answers my last question.

Cron can be tricky with some things but it's pretty simple generally. You just have fields where you set the times and the commands, with '*' standing for 'all slots'.

Like part of mine is
Code:
#MIN HOUR DAY MONTH DAYOFWEEK COMMAND
10 15 * * * /home/j/sbin/slackchange
So at 3:10PM every day, it runs that script.

The only thing to do is export VISUAL=your-favorite-editor and run 'crontab -e', like I say.

Last edited by slakmagik; 12-26-2004 at 08:54 PM.
 
Old 12-26-2004, 10:08 PM   #5
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Original Poster
Rep: Reputation: 34
Awesome! The script didn't work... but the one command line thing did the job, and so did killall.

Thanks a lot digiot I owe you one

Just one more question.. will it still run even if i am not logged onto my computer?

Last edited by student04; 12-26-2004 at 10:11 PM.
 
Old 12-26-2004, 10:18 PM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
No problem. Glad it's working.

As long as the machine's running, cron should.
 
  


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
Cron - doesn't seem to run scheduled tasks robintw Linux - General 11 11-25-2005 02:53 AM
What does cron do if machine is down when job is scheduled? Utah Linux - Software 4 08-24-2005 08:23 PM
newbie needing help creating a cron job Lleb_KCir Linux - Software 5 12-13-2004 04:58 PM
Cron - not creating log file t3___ Linux - Newbie 3 02-26-2004 07:50 PM
creating cron jobs jonfa Linux - General 5 05-26-2002 06:05 PM


All times are GMT -5. The time now is 05:48 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration