I use this command to run my work.
(time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt
While, 1 is a number of process that I use to run this work. I have to change the number of process for each run. At each time it use long time to complete. Then I want to run it as background process.
How can I do it?
I tried:
nohup ((time bash executeScript 1 input fileOutput $> scrOutput) &> timeUse.txt)
But it doesn't work.
To bring a process running in the background to the foreground, use the fg command followed by the job id. To put in the background again, press CTRL + Z followed by the bg command.
Run ping command with nohup command. Re-open the terminal and run pgrep command again. You will get the list of the process with process id which is running. You can stop any background process by running kill command.
In order to place a foreground proces into the background, we must first put the process to sleep, and then place it in the background. Execute the command to run your process. Press CTRL+Z to put the process into sleep. Run the bg command to wake the process and run it in the backround.
Nohup, short for no hang up is a command in Linux systems that keep processes running even after exiting the shell or terminal. Nohup prevents the processes or jobs from receiving the SIGHUP (Signal Hang UP) signal. This is a signal that is sent to a process upon closing or exiting the terminal.
In general, I use nohup CMD &
to run a nohup background process. However, when the command is in a form that nohup
won't accept then I run it through bash -c "..."
.
For example:
nohup bash -c "(time ./script arg1 arg2 > script.out) &> time_n_err.out" &
stdout from the script gets written to script.out
, while stderr and the output of time
goes into time_n_err.out
.
So, in your case:
nohup bash -c "(time bash executeScript 1 input fileOutput > scrOutput) &> timeUse.txt" &
You can write a script and then use nohup ./yourscript &
to execute
For example:
vi yourscript
put
#!/bin/bash script here
you may also need to change permission to run script on server
chmod u+rwx yourscript
finally
nohup ./yourscript &
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With