LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-09-2008, 12:07 AM   #1
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Rep: Reputation: 17
CronJob process


Hi,

Good Morning :-), I am system administrator, one of the user wants to setup cron job and run all the time, while he log out from the server.
how could be possible.
please help me out....
 
Old 09-09-2008, 12:23 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Each user has their own crontab that they can use (there may be some requirement to enable crontab for users, but on CentOS, which I use, it's enabled)

crontab -e

will allow them to edit/install their own crontab, and this will execute as requested once the user logs out. See man crontab for details
 
Old 09-09-2008, 05:10 AM   #3
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
Hi,
if you don't mind..
can you explain please, how to edit/install own crontab.is it continuous runs after log out by the user?
thanks :-)
 
Old 09-09-2008, 05:23 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The cron jobs do not require pseudo-terminal allocation to do their work, so they act indipendently from the user being logged in or not. As billymayday suggested, you have to be sure the cron daemon is running and the users are allowed to run their own crontab. If the user set a cron job at 4:00 AM, the cron daemon will do its work: run the user's job and send the standard error and the standard output to the user's mailbox, unless they have been explicitly redirected to a file.

Anyway, there is a chance the user really need to be logged in: if the cron job runs a program which requires a DISPLAY, that is a graphical application, the user must have the credentials to use an already assigned X environment. But he/she must explicitly set the DISPLAY variable into his/her job. It's not an easy task if the DISPLAY does not belong to the user itself.

Regarding the creation of a user crontab, see man crontab and man 5 crontab. The former explains the usage of crontab in general, the latter explains the format of the crontab file.

Last edited by colucix; 09-09-2008 at 05:24 AM.
 
Old 09-09-2008, 05:24 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Well the user would log in by some mechanism, and will need to open a terminal session (if they log in with ssh they are probably already there). They would then type "crontab -e", enter the relevant information (see man crontab) and exit. Exiting will install the new crontab and it should run auromatically if you have cron installed on your system. I don't know what distro you are using, but on all mine, editing crontab uses vim command (vim is an editor). You can search google for vim commands - they take a bit of getting used to.

Cron will execute so long as the machine is on, whether the user is logged in or not is irrelevant. Teh user can specify which minute of which hour of which day of the week or calendar day of which month command run (it is simple to specify every 5 minutes for example). Here is a typical line from one of my crontabs

Code:
# min   hr      mday    mon     dow
31      *       *       *       *       /home/common/read_spam.sh > /dev/null
This entry runs at 31 minutes past each hour and runs the script at /home/common called read_spam.sh (it just marks spam filtered email as read)

Last edited by billymayday; 09-09-2008 at 05:25 AM.
 
Old 09-09-2008, 07:56 AM   #6
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Quote:
Originally Posted by deepak_message View Post
is it continuous runs after log out by the user?
As others said, cron is about running your task at scheduled times. It's not primarily about running continuously, and independent of whether the user is logged out or in.

Maybe cron is not the solution to your user's problem. Can you describe what he/she is trying to achieve?

Thanks,
/Quigi
 
Old 09-09-2008, 02:08 PM   #7
valen_tino
Member
 
Registered: Jan 2008
Posts: 105

Rep: Reputation: 28
If you want to run it "all the time", then you can start the process with nohup. You should make an entry in /etc/rc.local for it.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob xser Linux - Software 6 07-27-2008 09:38 PM
cronjob help meeh Linux - General 1 03-26-2004 11:41 AM
Cronjob engnet Linux - Networking 6 03-03-2004 09:21 AM
cronjob ugob Linux - Software 0 03-03-2004 09:20 AM
Su in a cronjob michedlp Programming 3 11-06-2003 08:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:44 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