0

I am following this post. I want to run a python script, in the background, after logging out of ssh, witht the output stored into a specific file. Namely, I wish to use the following bash command:

nohup python3 main.py --dataset CorrSR/testTraining/small --train --input_height=256 --output_height=256 --epoch=2 | at 1:25 PM Mon > logs/background_run_small.txt &

I am not sure regarding the order of the command. is | before >? The command runs with no errors, though a process is immediately opened with

4285 pts/5 Sl 0:02 /usr/bin/python3 -u /usr/lib/python3/dist-packages/spyderlib/widgets/externalshell/start_ipython_kernel.p

and also the output file is immediately created. Is that normal? how do I know the program waits for the designated time to run?

SKi
  • 8,007
  • 2
  • 26
  • 57
havakok
  • 1,185
  • 2
  • 13
  • 45
  • 1
    (general suggestion) Consider starting a `screen` session instead of `nohup`. To fix your command you need to pipe the command to `at`, not the output of your command (`echo "xx --y" | at`). `at` does not need `nohup`. – liborm Aug 13 '18 at 10:53

1 Answers1

1

Your command line executes main.py immediately.

What you probably want is:

echo 'nohup python3 main.py --dataset CorrSR/testTraining/small --train --input_height=256 --output_height=256  --epoch=2 > logs/background_run_small.txt' | at "1:25 PM Mon"
Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271