QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 906|回复: 2

请问一个关于nohup的菜菜问题

[复制链接]
发表于 2003-10-12 00:41:43 | 显示全部楼层 |阅读模式
我在rc.local里设置一个程序开机启动

#bin/bash
cd /home/softwarez/CS/hlds
nohup ./cs &

可是我不知道该怎么关闭这个程序,在系统监视器kill了进程,但是事实上这个进程依然存在

我想知道的是如何在有需要的时候关闭该程序,或者重启该进程

谢谢
发表于 2003-10-12 03:22:36 | 显示全部楼层
这里没有必要用 nohup 吧?如果是希望输出内容不显示到屏幕上可以直接用 管道符将输出重定向到某个文件,或者干脆 /dev/null。

如果说你真的想做一个程序,比较好的办法是不要将它写在 rc.local 里,自己写一个 /etc/init.d 下的服务脚本,然后用 service 命令像控制普通系统服务一样控制这个程序 - start, stop, restart, reload ....

Gentoo 所使用的 BSD Style init 和 Redhat 所使用的 SysV init 格式不太一样,Gentoo 下的服务脚本非常好写,这里有个例子,是 esound 服务的内容:
[code:1]#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /home/cvsroot/gentoo-x86/media-sound/esound/files/esound.init.d,v 1.2 2003/05/30 22:55:56 utx Exp $

# Note: You need to start esound on boot, only if you want to use it over network.

# Warning: To use global esound daemon, you must also set spawn_options
# in /etc/esd/esd.conf to the same protocol (i. e. add "-tcp") and unset
# "Enable sound server startup" in gnome-sound-properties for all users
# and optionally handle authentization.

. /etc/conf.d/esound

depend() {
        use net portmap
}

start() {
        ebegin "Starting esound"
        start-stop-daemon --start --quiet --background --exec /usr/bin/esd -- $ESD_START $ESD_OPTIONS
        eend $?
}

stop() {
        ebegin "Stopping esound"
        start-stop-daemon --stop --quiet --exec /usr/bin/esd
        eend $?
}[/code:1]
回复

使用道具 举报

 楼主| 发表于 2003-10-12 16:51:15 | 显示全部楼层
我也不懂这儿是否需要nohup ;p,平时启动用nohup,所以一块儿写到rc.local里去了
我用的是rh,去看看脚本该怎么写,不会再回来请教,thx
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-22 04:32 , Processed in 0.073138 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表