Linux nohup command

Source: Internet
Author: User
Tags exit in touch command
Linux's nohup command-Linux general technology-Linux technology and application information. The following is a detailed description. Wget a file in the shell of DreamHost last night and want to upload it to my ftp, but it is anxious to go home for dinner. Put the ftp command. Once the connection is disconnected, the transfer will stop. I think Windows has at commands. Linux should have timed execution functions. I checked it online and found this Linux background task. In the past, I only needed to add the & Symbol after the command to run the task in the background. However, this only allows the task to be executed in the background, and the disconnection will end. So I used the following command:

Nohup ncftpput-u yskin-p *** ftp.server.com/wwwroot 123.zip &

After the command is executed, run the jobs command to check that he is running. Then run the exit command to exit the shell. ftp is sent to my ftp server and the file size keeps increasing. I accessed the Internet this morning and found that the file has been uploaded. Sleeping on your own makes the machine work. It's so nice!

It seems that the jobs command can only display jobs in the current connection, but it will not be displayed after telnet. In addition, I found that the file time on the ftp server has been set. It seems that the ncftpput program will automatically set the File Upload time, the ftp client I have used does not seem to have such a function. I will check it later.

Update: I am particularly interested in studying this question today: how to modify the remote file time on the ftp server in FTP. "-Y Try using 'site utime' to preserve timestamps on remote host." seems to be using the "site utime" command to modify the remote file time. On the Internet, I found that Not supported remote FTP servers support this, so it may not work. after a try, neither of my FTP servers supports this command, and Serv-U does not. Helpless, go to the ncftp official website and download the NcFTP Client source code. Use WinRAR to search for "UTIME" and find the c_utime.c file, which is clearly written, try modifying the "site utime" command first. You cannot use the MDTM command to modify it. I tried it. I logged on using the ftp command, typed the quote MDTM 20060101000000 filename, and the modification was successful.

In addition, I also found that the last modification time of the file can be modified using the touch () function in PHP, which is the same as the name of the touch command in Linux, hoho

Update2: It seems that vsFTPd 2.0.3 on Serv-u ftp Server v6.0 and yskin.net on my FTP Server supports MDTM commands, while ProFTPD 1.3.0rc2 Server of DreamHost does not support MDTM commands. So, only telnet. Use the touch command to change it.

Update3: Linux screen program is recommended for Kirin Lin. Go to Google and find terminal software that is not suitable for unattended use of Screen and Unix/Linux tool: Screen command usage. This tool is equivalent to running another shell in the shell, just like logging on to the shell and then entering the bash command, or enter Win + R-> cmd in the Windows command line prompt and then press Enter. However, this new shell can be paused at any time, and it is still running after it is logged out, and can be logged in again next time.

The command is very simple. screen-S test creates a screen named test. You can run the program in this screen. Assume that I am running python:

[Burns] $ python
Python 2.5 (r25: 51908, Nov 23 2006, 19:51:08)
[GCC 3.3.5 (Debian. 3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Okay, I admit that I'm showing off the Python 2.5 I just installed on DreamHost. The specific installation process is described here.

Press Ctrl + a, and then press d. "[detached]" is displayed, indicating that the screen is disconnected. Then, run the screen-ls command to view the information.

[Burns] $ screen-ls
There is a screen on:
1906. test (Detached) 1 Socket in/var/run/screen/S-yskin.
A disconnected screen is displayed. Enter exit, exit shell, and then telnet in. By typing the screen-ls command, we can find that my cute screen named test is still lying there. As long as the DreamHost host does not restart, this screen should always exist. Enter screen-r test to reconnect to the screen (because I gave it the name "test", or I must remember the 1906 number), and my python is still there. Press Ctrl + D to exit python, and then enter exit to exit the screen. The screen will display "[screen is terminating]". Well, terminating, this word is familiar. I heard it yesterday when I read Terminator III.

Windows command line prompts and Linux bash can be divided into many layers, but you need to enter exit at one layer to exit. Er, try to open another screen in A screen, press Ctrl + A-> D to exit, and the first screen will be exited directly. Run the screen-ls command to check whether the first layer is disconnected and the second layer is connected. I don't know what the result will be if I open multiple layers and then use the-D command to force stop a layer in the middle.

After learning Linux for a few days, I found that Linux is really more fun than DOS.

Update3: Use the nohup command to directly run the command in the background. If you use screen, even if the telnet is disconnected during a screen, you can log on to the screen and switch to the screen to access the page before the screen is disconnected. However, if the ncftpput command is used, screen will not be closed after the command is executed. DOS has an & Symbol. You can run several commands one after another. (For Windows, it should be "&", and for pure DOS, it should be Ctrl + T.) I tried it in Linux. The "&" symbol indicates that multiple commands are run simultaneously and run in multiple threads. Therefore, ncftpput is still running. screen has exited and the bash process opened by screen has stopped. However, this ncftpput can continue to run until the uploaded file is closed by itself. And | and <还有> Is the pipeline symbol. A semicolon (;) was found by accident when I entered the wrong command ;. Commands with Semicolons can be run successively. Input ncftpput...; exit in screen. After ncftpput is uploaded, the screen will be automatically disabled. hoho

Also learned two Commands: ps-e to view the process and kill-9 + process number to forcibly close the process.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.