LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: litty

如何写一个cron执行的关机脚本?[基本解决]

[复制链接]
发表于 2004-4-10 14:16:37 | 显示全部楼层
贴出"command init"这个命令的输出来看看。
 楼主| 发表于 2004-4-10 14:21:07 | 显示全部楼层
最初由 home_king 发表
贴出"command init"这个命令的输出来看看。


[litty@litty litty]$ command init
bash: init: command not found
[litty@litty litty]$
 楼主| 发表于 2004-4-10 14:23:29 | 显示全部楼层
最初由 home_king 发表
贴出"command init"这个命令的输出来看看。



[litty@litty litty]$ command init
bash: init: command not found
[litty@litty litty]$ su
Password:
bash-2.05b# command init
bash: init: command not found
bash-2.05b# init
bash: init: command not found
bash-2.05b#
发表于 2004-4-10 14:24:30 | 显示全部楼层
最初由 litty 发表
[litty@litty litty]$ command init
bash: init: command not found
[litty@litty litty]$

难怪,你一个普通用户,当然不能使用init命令啦(可能/sbin不在$PATH里),只能使用halt了。
呵呵,还以为你是管理员呢。
发表于 2004-4-10 14:27:41 | 显示全部楼层
最初由 litty 发表
[litty@litty litty]$ command init
bash: init: command not found
[litty@litty litty]$ su
Password:
bash-2.05b# command init
bash: init: command not found
bash-2.05b# init
bash: init: command not found
bash-2.05b#

哦?你用的是什么发行版本呢?init都没有?莫非BSD风格的启动脚本没有init?还是bash配置文件有问题?没有设置好$PATH?
whereis init
 楼主| 发表于 2004-4-10 14:29:28 | 显示全部楼层
我按照斑竹说的把脚本写好了。然后我将crontab这样做,不知行不行:


[litty@litty litty]$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.4365 installed on Sun Apr 11 14:19:58 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
38 22 * * 0,1,2,3,4 wall "Time is up!Shutdown the computer!"
38 23 * * 5,6 wall"Time is up!Shutdown the computer!"
41 22 * * 0,1,2,3,4 konsole --noclose -e /home/litty/bin/sdit
41 23 * * 5,6 konsole --noclose -e /home/litty/bin/sdit
 楼主| 发表于 2004-4-10 14:32:40 | 显示全部楼层
最初由 home_king 发表
哦?你用的是什么发行版本呢?init都没有?莫非BSD风格的启动脚本没有init?还是bash配置文件有问题?



我用的是redhat9啊,你们的redhat有啊?
发表于 2004-4-10 14:33:39 | 显示全部楼层
最初由 litty 发表
41 22 * * 0,1,2,3,4 konsole --noclose -e /home/litty/bin/sdit
41 23 * * 5,6 konsole --noclose -e /home/litty/bin/sdit

嗯,试试看吧。

init是很重要的命令哦。
whereis init给在下看看。
 楼主| 发表于 2004-4-10 14:39:18 | 显示全部楼层
最初由 home_king 发表
哦?你用的是什么发行版本呢?init都没有?莫非BSD风格的启动脚本没有init?还是bash配置文件有问题?没有设置好$PATH?
whereis init



好奇怪。
bash-2.05b# init
bash: init: command not found
bash-2.05b# whereis init
init: /usr/src/linux-2.4.20-8/init /usr/src/linux-2.4/init /sbin/init /etc/init.d /usr/share/man/man8/init.8.gz
bash-2.05b# /sbin/init
Usage: init 0123456SsQqAaBbCcUu
发表于 2004-4-10 14:42:12 | 显示全部楼层
最初由 litty 发表
好奇怪。
bash-2.05b# init
bash: init: command not found
bash-2.05b# whereis init
init: /usr/src/linux-2.4.20-8/init /usr/src/linux-2.4/init /sbin/init /etc/init.d /usr/share/man/man8/init.8.gz
bash-2.05b# /sbin/init
Usage: init 0123456SsQqAaBbCcUu

看看你的/etc/profile有没有这一段:

  1. [root@home root]# cat /etc/profile
  2. # /etc/profile

  3. # System wide environment and startup programs, for login setup
  4. # Functions and aliases go in /etc/bashrc

  5. pathmunge () {
  6.         if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
  7.            if [ "$2" = "after" ] ; then
  8.               PATH=$PATH:$1
  9.            else
  10.               PATH=$1:$PATH
  11.            fi
  12.         fi
  13. }

  14. # Path manipulation
  15. if [ `id -u` = 0 ]; then
  16.         pathmunge /sbin
  17.         pathmunge /usr/sbin
  18.         pathmunge /usr/local/sbin
  19. fi
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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