Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cron job doesn't output to nohup.out

i have start.sh bash script that is running though CRON JOB on ubuntu server

start.sh contains bellow mentioned lines of code

path of start.sh is /home/ubuntu/folder1/folder2/start.sh

#!/bin/bash

crawlers(){
    nohup scrapy crawl first &
    nohup scrapy crawl 2nd &
    wait $!
    nohup scrapy crawl 3rd &
    nohup scrapy crawl 4th &
    wait
}

cd /home/ubuntu/folder1/folder2/
PATH=$PATH:/usr/local/bin
export PATH

python init.py &
wait $!
crawlers
python final.py

my issue is if i run start.sh my myself on command line it outputs in nohup.out file

but when it executes this bash file through cronjob (although scripts are running fine) its not producing nohup.out

how can i get output of this cronjob in nohup.out ?

like image 429
akhter wahab Avatar asked Jan 03 '13 18:01

akhter wahab


1 Answers

Why are you using nohup? nohup is a command that tells the running terminal to ignore the hangup signal. cron, however, has no hangup signal, because it is not linked to a terminal session.

In this case, instead of:

nohup scrapy crawl first &

You probably want:

scrapy crawl first > first.txt &

The last example also works in a terminal, but when you close the terminal, the hangup signal (hup) is sent, which ends the program.

like image 164
Fredrick Brennan Avatar answered Oct 30 '22 13:10

Fredrick Brennan