Solved

Nohup problem in crontab

Posted on 2001-08-16
6
3,437 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
Comment Utility
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
Comment Utility
Crontab line shoul of course be :
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.log 2>&1
0
 

Author Comment

by:hln_01
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

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

Expert Comment

by:paulqna
Comment Utility
"...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
Comment Utility
thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

10 Experts available now in Live!

Get 1:1 Help Now