zoukankan      html  css  js  c++  java
  • centos 后台执行C#控制台程序

    1. nohup

    nohup 无疑是我们首先想到的办法。顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号。让我们先来看一下 nohup 的帮助信息:

    NOHUP(1)                        User Commands                        NOHUP(1)
    
    NAME
           nohup - run a command 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 information and exit

    可见,nohup 的使用是十分方便的,只需在要处理的命令前加上 nohup 即可,标准输出和标准错误缺省会被重定向到 nohup.out 文件中。一般我们可在结尾加上"&"来将命令同时放入后台运行,也可用">filename 2>&1"来更改缺省的重定向文件名。

    接着可以使用mono 直接执行。

    nohup mono Server.exe >log.out 2>&1 &
    或者
    setsid 
    mono Server.exe

    如果需要停止后台进程首先执行

    ps -aux

    找到相应的进程id,接着直接kill掉

    kill 17969
    screen 示例
    [root@pvcent107 ~]# screen -dmS Urumchi
    [root@pvcent107 ~]# screen -list
    There is a screen on:
            12842.Urumchi   (Detached)
    1 Socket in /tmp/screens/S-root.
    
    [root@pvcent107 ~]# screen -r Urumchi
  • 相关阅读:
    dede首页调用分类信息
    install sphinx
    rails新环境
    互联网创业三件事:钱、人和项目
    Remove Duplicate Elements from an Array using jQuery
    rails新环境
    rails新环境
    牛人
    电动车电池
    rails新环境
  • 原文地址:https://www.cnblogs.com/cheng5x/p/5666443.html
Copyright © 2011-2022 走看看