Solved

Nohup problem in crontab

Posted on 2001-08-16
6
3,561 Views
Last Modified: 2013-12-26
How to schedule a cronjob with nohup to run on particular time? For example like this :where the job is running on different directory as the crontab.

15 8 * * * nohup ./tmp/jobs/startjob &

is this the right way to do it?
I'd try but not working at all.....

please do assist.

Thanks
0
Comment
Question by:hln_01
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
paulqna earned 20 total points
ID: 6392665
You need to create a script containing the nohup

Script example (/tmp/cronjob.sh):
nohup /tmp/jobs/startjob &

Crontab example:
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.sh 2>&1
0
 
LVL 5

Expert Comment

by:paulqna
ID: 6392672
Crontab line shoul of course be :
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.log 2>&1
0
 

Author Comment

by:hln_01
ID: 6395502
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.log 2>&1

Why I need this >>/tmp/cronjob.log 2>&1 after my script?
And what does this &1 mean?



0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:hln_01
ID: 6395670
How can I quit my script while the nohup job is actually running?  
0
 
LVL 5

Expert Comment

by:paulqna
ID: 6396555
"...Why I need this >>/tmp/cronjob.log 2>&1 after my script?..."
--> This prevents any outputmail to be send to the cronjob owner? This is not required.

"...And what does this &1 mean?..."
--> This means all errors are redirected to the same file as non-error messages. You could also say :
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.log 2>>/tmp/cronjob.log

"...How can I quit my script while the nohup job is actually running?..."
--> Don't know if i understood this question, the "/tmp/cronjob.sh" script exit's automatically after executing the last line. Would in this case be after:
nohup /tmp/jobs/startjob &
and leaves the nohup job running.
0
 

Author Comment

by:hln_01
ID: 6405338
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 111
Hibernate methods 2 68
sumHeights  challenge 17 66
sumHeights2  challenge 7 87
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now