简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM