1. The first method is to use the unhup command directly to let the program run in the background. The command format is as follows: unhup python filename.py (> ***.log )& In this command, python specifies that the file we want to execute is a python file, and the following file name .py is the file we want to execute. The content in brackets indicates that the content normally output to the console can be redirected to the *.log file. This is optional. If this is not done, the content will be output to the nohup.out file by default. The & after the brackets indicates background execution. 2. The second method is to write a script, submit the script to the server, and let the server run the statements in the script in the background. Suppose we define a script start.sh with the following content: #!/bin/bash cd the path name of the file you want to run python -u ***.py In the above script, #!/bin/bash means that this script uses /bin/bash to interpret and execute the following statements, where cd means jumping the current directory to the directory where the file to be run is located, and python -u ***.py means running the ***python file. After writing the script, we can use the following command to execute the script so that the program can run in the background: ./start.sh > result.log & Here, ./start.sh means running the script start.sh in the current directory, > result.log means outputting everything originally output to the console to the result.log file, and & means running in the background We can use the ps -e command to view the processes running in the background. In the above figure, we can see that our script start.sh and Python program have been successfully run in the background. Then we can view the information originally output to the console through cat result.log | more Note: To execute a function in a Python file, you must remember to call the function in the file in addition to defining the function. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: How to modify the IP restriction conditions of MySQL account
>>: Comprehensive explanation of CocosCreator hot update
The Linux command line provides many commands to ...
Original address: http://www.webdesignfromscratch...
Table of contents 1. df command 2. du command 3. ...
Introduction to temporary tables What is a tempor...
Enable remote access rights for mysql By default,...
1. Install components yum install epel-rpm-macros...
1. Install zabbix-agent on web01 Deploy zabbix wa...
I haven’t updated my blog for several days. I jus...
Commonly used JavaScript code to detect which ver...
MySQL Bin log data recovery: accidentally delete ...
With the development of Internet technology, user...
HTML web page list tag learning tutorial. In HTML ...
Table of contents What is the rest operator? How ...
Table of contents What are hooks? Class Component...
When using MYSQL, triggers are often used, but so...