Cron task is not displayed on nohup.out

I have a start.sh bash script that runs CRON JOB on an ubuntu server

start.sh contains the following lines of code

start.sh path - /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 problem is that if I run start.sh mine myself on the command line, it is displayed in the nohup.out file

but when it executes this bash file via cronjob (although the scripts work fine), it does not create nohup.out

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

+8
python bash cron ubuntu crontab
source share
1 answer

Why are you using nohup ? nohup is a command that tells the current terminal to ignore the hang signal. cron , however, does not have a hang signal because it is not associated with 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 the terminal, but when you close the terminal, a hover signal is sent that terminates the program.

+14
source share

All Articles