Im going to have to run a nohup command that will run for months and generate tons of logs, so I want to write the nohup.out file to a directory that contains the rest of the code. My simple script to execute on every startup is:
sudo su ubuntu
cd /home/ubuntu/folder
nohup /home/ubuntu/folder/start_server.sh&
If I do a crontab job that runs the script, all of the nohup logs still go into /var/log/syslog
.
If I do the same with cloud-init since im working on ec2, all logs into /var/log/cloud-init-output.log
.
How can I make nohup run in a choosen directory (/home/ubuntu/folder
in my case) only?
CodePudding user response:
The solution was to run crontab with my starting script running nohup /home/ubuntu/folder/start_server.sh > nohup.out
instead of just nohup /home/ubuntu/folder/start_server.sh&