手机
当前位置:查字典教程网 >电脑 >服务器_操作系统教程 >LINUX如何设置自动运行程序?
LINUX如何设置自动运行程序?
摘要:这里小编介绍Linux中的cron命令和at命令,来设置LINUX自动运行程序。但是一些命令知识并不清楚,所以小编来帮助大家提升LINUX操...

这里小编介绍Linux中的cron命令和at命令,来设置LINUX自动运行程序。但是一些命令知识并不清楚,所以小编来帮助大家提升LINUX操作系统的命令知识,欢迎大家来阅读!!!

LINUX如何设置自动运行程序?

crontab文件的存放路径是/etc/crontab


cron用来执行周期性的事件,cron命令有个一个特殊的文件与之对应,内容如下

[oracle@golonglee spool]$ cat /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# For details see man 4 crontabs

# Example of job definition:

# .---------------- minute (0 - 59)

# | .------------- hour (0 - 23)

# | | .---------- day of month (1 - 31)

# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...

# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * user-name command to be executed

[oracle@golonglee spool]$


Linux的启动模式可通过inittab文件进行配置,下面是inittab文件的内容

# cat /etc/inittab

# inittab is only used by upstart for the default runlevel.

#

# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.

#

# System initialization is started by /etc/init/rcS.conf

#

# Individual runlevels are started by /etc/init/rc.conf

#

# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf

#

# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,

# with configuration in /etc/sysconfig/init.

#

# For information on how to write upstart event handlers, or how

# upstart works, see init(5), init(8), and initctl(8).

#

# Default runlevel. The runlevels used are:

# 0 - halt (Do NOT set initdefault to this)

# 1 - Single user mode

# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)

# 3 - Full multiuser mode

# 4 - unused

# 5 - X11

# 6 - reboot (Do NOT set initdefault to this)

#

id:5:initdefault:

# 这里的【id:5:initdefault:】就是说本系统默认是以X11也就是x-window的模式启动。


Runlevel 0 ——init关闭所有进程并终止系统。

Runlevel 1 ——转到单用户模式

Runlevel 2 ——进入多用户的模式

Runlevel 3 ——多用户模式,也是多数服务器的默认模式。

Runlevel 4 —— 一般不使用,可以实现一些特定的登录请求。

Runlevel 5 ——X Window终端。

Runlevel 6 ——是关闭进程并重新启动系统。


/etc/rc开头的文件,一般都是系统启动后自动执行的文件。rc开头的文件很多,如下:

rc rc1.d/ rc3.d/ rc5.d/ rc.d/ rc.sysinit

rc0.d/ rc2.d/ rc4.d/ rc6.d/ rc.local

其中init是所有进程之父 init读取/etc/inittab,执行rc.sysinit脚本


运行顺序由inittab中设置的init tree决定,一般设置为: /etc/rc.d/rc0.d /etc/rc.d/rc1.d /etc/rc.d/rc2.d /etc/rc.d/rc3.d /etc/rc.d/rc4.d /etc/rc.d/rc5.d /etc/rc.d/rc6.d /etc/rc.d/rc.local

其中/etc/rc.d/rc.local默认是用户自定义的脚本


/etc/rc.d/rc.local文件内容如下:

[root@golonglee etc]# cat /etc/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

经常使用的 rc.local 则完全是习惯问题,不是标准。不过使用 rc.local是个好习惯。


相关介绍:Linux

Linux是一种自由和开放源代码的类UNIX操作系统。

Linux拥有以下特性:类似于Unix的基本思想,支持完全免费与自由传播,完全兼容POSIX1.0标准,支持多用户、多任务、有着良好的界面、支持多种平台。Linux是一个性能稳定的多用户网络操作系统。

Linux有着许多不同的版本。Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、视频游戏控制台、台式计算机、大型机和超级计算机。

【LINUX如何设置自动运行程序?】相关文章:

U盘做的启动盘如何启动电脑?

如何获得Linux系统的内置模块和设备驱动列表

Linux blockdev命令设置文件预读大小

如何设置Squid Cache_mem大小

如何在Linux系统上加密文件和目录

LINUX系统:如何配置管理APACHE服务器?

LINUX系统教程:如何安装nginx?

LINUX系统教程:如何远程登录桌面

ubuntu如何启动命令行

LINUX系统怎么使用命令清理磁盘空间?

精品推荐
分类导航