nohup and &, process background running, viewing, termination

nohupThe command can make the command execute permanently, and it has nothing to do with the terminal, and exiting the terminal will not affect the running of the program;
&it means running in the background, but when the user exits, the command automatically exits.
Then, combine the two nohup 命令 &so that the command is permanently executed in the background

Take the run_train.shfile as an example

source env_set.sh

nohup python -u train_image_classifier.py \
  --dataset_name=$DATASET_NAME \
  --dataset_dir=$DATASET_DIR \
  --checkpoint_path=$CHECKPOINT_PATH \
  --model_name=inception_v4 \
  --checkpoint_exclude_scopes=InceptionV4/Logits,InceptionV4/AuxLogits/Aux_logits \
  --trainable_scopes=InceptionV4/Logits,InceptionV4/AuxLogits/Aux_logits \
  --train_dir=$TRAIN_DIR \
  --learning_rate=0.001 \
  --learning_rate_decay_factor=0.76\
  --num_epochs_per_decay=50 \
  --moving_average_decay=0.9999 \
  --optimizer=adam \
  --ignore_missing_vars=True \
  --batch_size=32 > output.log 2>&1 &

    
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

To run the program in TensorFlow, run_train.shadd nohup 命令 > output.log 2>&1 &the command before and after the file to execute the command in the background.

0, 1, and 2 represent the following meanings:
0 – stdin (standard input)
1 – stdout (standard output)
2 – stderr (standard error)

nohup+ The last &is to let the command execute in the background

>output.logis to output information to the output.log log

2>&1It is to convert the standard error information into standard output, so that the error information can be output to the output.log log.


  • View log (dynamic display)

    tail -f output.log
          
          
    • 1
  • View the log (show the entire file at once)

    cat output.log
          
          
    • 1

  • View the current Python process

    ps -ef |grep python
          
          
    • 1
  • kill process

    sudo kill 进程号
          
          
    • 1
    kill 9 进程号 #绝杀
          
          
    • 1

nohupThe command can make the command execute permanently, and it has nothing to do with the terminal, and exiting the terminal will not affect the running of the program;
&it means running in the background, but when the user exits, the command automatically exits.
Then, combine the two nohup 命令 &so that the command is permanently executed in the background

Take the run_train.shfile as an example

source env_set.sh

nohup python -u train_image_classifier.py \
  --dataset_name=$DATASET_NAME \
  --dataset_dir=$DATASET_DIR \
  --checkpoint_path=$CHECKPOINT_PATH \
  --model_name=inception_v4 \
  --checkpoint_exclude_scopes=InceptionV4/Logits,InceptionV4/AuxLogits/Aux_logits \
  --trainable_scopes=InceptionV4/Logits,InceptionV4/AuxLogits/Aux_logits \
  --train_dir=$TRAIN_DIR \
  --learning_rate=0.001 \
  --learning_rate_decay_factor=0.76\
  --num_epochs_per_decay=50 \
  --moving_average_decay=0.9999 \
  --optimizer=adam \
  --ignore_missing_vars=True \
  --batch_size=32 > output.log 2>&1 &

  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

To run the program in TensorFlow, run_train.shadd nohup 命令 > output.log 2>&1 &the command before and after the file to execute the command in the background.

0, 1, and 2 represent the following meanings:
0 – stdin (standard input)
1 – stdout (standard output)
2 – stderr (standard error)

nohup+ The last &is to let the command execute in the background

>output.logis to output information to the output.log log

2>&1It is to convert the standard error information into standard output, so that the error information can be output to the output.log log.


  • View log (dynamic display)

    tail -f output.log
        
        
    • 1
  • View the log (show the entire file at once)

    cat output.log
        
        
    • 1

  • View the current Python process

    ps -ef |grep python
        
        
    • 1
  • kill process

    sudo kill 进程号
        
        
    • 1
    kill 9 进程号 #绝杀
        
        
    • 1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326010477&siteId=291194637