查看完整版本: SSH登录linux妙用后台命令

谐和 2008-7-3 10:01

SSH登录linux妙用后台命令

  用SSH管理linux[url=http://server.ctocio.com.cn/]服务器[/url],有时可能要下载点大的软件或者文件包.又或者要打包一个上5G的文件夹,那是多么漫长的等待.
  更麻烦的是,下载的时候如果SSH 客户端N久没动作会断掉连接,于是下载到一半的东西也会跟着死掉.
  当然,你说我可以打开多个SSH客户窗口来操作,那我不得不说,这是个笨办法.
  比如我想打包一个文件夹,可以用如下的命令
  #[url=http://whatis.ctocio.com.cn/searchwhatis/85/6092585.shtml]tar[/url] zcvf [url=http://whatis.ctocio.com.cn/searchwhatis/398/5947898.shtml]file[/url].tar.gz /[url=http://whatis.ctocio.com.cn/searchwhatis/448/6025948.shtml]path[/url]/document/*
  不想等,就把他放到后台去(后面加个&)
  #tar zcvf file.tar.gz /path/document/* &
  如果你要回来.就使用fg 命令
  我们想当然的,下载也是这样
  #wget [url]http://www.phpv[url=http://whatis.ctocio.com.cn/searchwhatis/261/5949261.shtml].net[/url]/file.tar.gz[/url] &
  但如果你超时或者有事离开而退出SSH 那正在下载的file.tar.gz 文件也会随之停下了...
  怎么办?让我们用nohup 来完成/
  NAME
  nohup - run a [url=http://whatis.ctocio.com.cn/searchwhatis/311/5947311.shtml]command[/url] immune to hangups, with output to a non-tty
  SYNOPSIS
  nohup COMMAND [ARG]...
  nohup OPTION
  DESCRIPTION
  Run COMMAND, ignoring hangup signals.
  --help display this help and exit
  --version
  output version [url=http://whatis.ctocio.com.cn/searchwhatis/11/6025511.shtml]information[/url] and exit
  REPORTING BUGS
  Report bugs to .
  SEE ALSO
  The full documentation for nohup is maintained as a Texinfo manual. If
  the info and nohup programs are properly installed at your site, the
  command
  info nohup
  should give you [url=http://database.ctocio.com.cn/databaseprogramme/tt-database-dpa/]access[/url] to the complete manual.
  以上是man nohup出来的.
  用法很简单,就在命令前加 nohup
  #nohup wget [url]http://www.phpv.[url=http://whatis.ctocio.com.cn/searchwhatis/325/6025825.shtml]net[/url]/file.tar.gz[/url]
  nohup: appending output to `nohup.out'
  没反映...死机了?
  CTRL+Z 回到命令行模式...
  要避免上面的方法,就加个 & 在命令后面
  #nohup wget [url]http://www.phpv.net/file.tar.gz[/url] &
  #
  好了.现在随便你怎样exit,睡一觉回来看,什么工作都完成了.

seenkate 2008-10-11 22:01

谢谢分享

谢谢分享

seenkate 2008-10-12 15:24

那么少人啊

那么少人啊?
页: [1]
查看完整版本: SSH登录linux妙用后台命令