Link to home
Start Free TrialLog in
Avatar of hln_01
hln_01

asked on

Nohup problem in crontab

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
ASKER CERTIFIED SOLUTION
Avatar of paulqna
paulqna
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Crontab line shoul of course be :
15 8 * * * /tmp/cronjob.sh >>/tmp/cronjob.log 2>&1
Avatar of hln_01
hln_01

ASKER

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?



Avatar of hln_01

ASKER

How can I quit my script while the nohup job is actually running?  
"...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.
Avatar of hln_01

ASKER

thanks