深度linux启动项,Autostart_program - deepin Wiki

Summary

This entry gives bref introduction to setting and managing of autostart program in Linux.

Using graphical interface

Open launcher, right click on the program you would like to autostart, and choose "Add to startup".

Managing configuration files

Autostart programs when starting system

Generally, init process is started after Linux kernel is loaded. It then initializes hardware and drivers, and continues to start other processes according to configuration files. These configurations are usually stored in following directories:

/etc/rc

/etc/rc.d

/etc/rcX.d

where X is 0, 1, 2, 3, 4, 5, 6 or S.

The script files in these directories can be executed to start other programes. For example, appending "xinit" or "startx" to file "/etc/rc.d/rc.local" (the script that is last executed during startup) will cause desktop environment to show.

Add autostart command in ~/.config/autostart

Take proxy tool XX-Net as example. Suppose its starting script is located in "~/Documents/XX-Net-3.3.1/start". We nned to add XX-Net.desktop under "~/.config/autostart":

[Desktop Entry]

Type=Application

Exec="/home/wy/Documents/XX-Net-3.3.1/start"

Hidden=false

NoDisplay=false

X-GNOME-Autostart-enabled=true

Name[en_IN]=XX-Net

Name=XX-Net

Comment[en_IN]=XX-Net

Comment=XX-Net

The next time when user logs in, the command after "Exec=" will be executed automatically.

Run program when login

When user logs in, bash will first execute global login script made by system administrator, "/etc/profile".

Then search for one of the following files in user's home directory:

/.bash_profile

/.bash_login

/.profile

And run the first one it founds. So it is easy to run certain program during login, by adding commands to the files above.

Run program when logout

When user logs out, bash will first execute the personal login script, "~/.bash_logout".

For example, in order to run command "tar" for backing up all ".c" files, append command

tar -cvzf c.source.tgz *.c

to file ~/.bash_logout.

Run programs regularly

Linux uses a daemon process called crond to regularly check the content of files in /var/spool/cron, then executes the commands in them on the specified time. Users can use command "crontab" to create, modify or remove these files.

For example, create a file called "cronFile" with content "00 9 23 Jan * HappyBirthday", then run command

crontab cronFile

After that, system will run program "HappyBirthday" at 9:00 in every January 23.

Run program once at a certain time

Like crond, at runs commands at a certain time, but only once.

Syntax:

at [ -f File ] Time

"File" contains the commands wanted to execute. Users may also input commands directly from keyboard:

$ at 12:00

at> mailto Roger -s ″Have a lunch″ < plan.txt

at> (Ctrl-D)

Job 1 at 2000-11-09 12:00

After that, system will automatically send an email to Roger with title "Have a lunch" and body text from plan.txt, at 12:00 in November 9, 2000.

Reference

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值