如何通过cron设置开机启动某个程序

70 views
Skip to first unread message

伊现富

unread,
Feb 16, 2011, 7:54:36 AM2/16/11
to shlug
我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
谢谢!

znetor

unread,
Feb 16, 2011, 8:03:24 AM2/16/11
to sh...@googlegroups.com
如果你用ubuntu 的话  用这个玩意吧

在 System -> Preferences -> Startup Applications ...


Startup Applications Preferences_017.png

在 2011年2月16日 下午8:54,伊现富 <yixf...@gmail.com>写道:
我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
谢谢!



--

http://znetor.tk:666


Startup Applications Preferences_017.png

duxiu xiang

unread,
Feb 16, 2011, 8:05:06 AM2/16/11
to sh...@googlegroups.com
可是Linux开机怎么自动输入账号密码?
--
笑看嫣红染半山,逐风万里白云间。
Startup Applications Preferences_017.png

丁一恒

unread,
Feb 16, 2011, 8:05:26 AM2/16/11
to sh...@googlegroups.com
man crontab

znetor

unread,
Feb 16, 2011, 8:08:36 AM2/16/11
to sh...@googlegroups.com
你指自动登录吗?
在 system -> administration -> login screen 

Login Screen Settings_018.png
Login Screen Settings_018.png
Startup Applications Preferences_017.png

Lightning

unread,
Feb 16, 2011, 8:10:21 AM2/16/11
to sh...@googlegroups.com
这个不关cron的事情,看一下at命令的手册,可以把at 命令写在rc.local里执行。

于 2011年02月16日 20:54, 伊现富 写道:
> 我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
> 谢谢!

duxiu xiang

unread,
Feb 16, 2011, 8:10:42 AM2/16/11
to sh...@googlegroups.com
对啊~
--
笑看嫣红染半山,逐风万里白云间。
Login Screen Settings_018.png
Startup Applications Preferences_017.png

znetor

unread,
Feb 16, 2011, 8:13:30 AM2/16/11
to sh...@googlegroups.com
有GUI 就尽量用嘛 哈哈~
Login Screen Settings_018.png
Startup Applications Preferences_017.png

Bryton Lee

unread,
Feb 16, 2011, 10:01:09 AM2/16/11
to sh...@googlegroups.com
哥们你这图上得让我这手机收邮件的订阅者内牛满面呀。。。呵呵,开个玩笑,可以做成附件吗?

On Wednesday, February 16, 2011, znetor <zne...@gmail.com> wrote:
> 有GUI 就尽量用嘛 哈哈~
>
> 在 2011年2月16日 下午9:10,duxiu xiang <xiangd...@gmail.com>写道:
>
> 对啊~
>
> 在 2011年2月16日 下午9:08,znetor <zne...@gmail.com>写道:
>
>
> 你指自动登录吗?在 system -> administration -> login screen
>
> </mail/s/?view=att&th=12e2e9aaae0d3afa&attid=0.1&disp=emb&realattid=ii_12e2e95417e45585&zw>

> 在 2011年2月16日 下午9:05,duxiu xiang <xiangd...@gmail.com>写道:
>
>
> 可是Linux开机怎么自动输入账号密码?
>
> 在 2011年2月16日 下午9:03,znetor <zne...@gmail.com>写道:
>
>
>
>
> 如果你用ubuntu 的话 用这个玩意吧
> 在 System -> Preferences -> Startup Applications ...
>
> </mail/s/?view=att&th=12e2e9aaae0d3afa&attid=0.2&disp=emb&realattid=ii_12e2e8feccf6e7cd&zw>

>
> 在 2011年2月16日 下午8:54,伊现富 <yixf...@gmail.com>写道:
>
>
>
>
>
> 我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
> 谢谢!
>
>
> --
>
> http://znetor.tk:666
>
>
>
>
> --
> 笑看嫣红染半山,逐风万里白云间。
>
>
> --
>
> http://znetor.tk:666
>
>
>
>
>
> --
> 笑看嫣红染半山,逐风万里白云间。
>
>
> --
>
> http://znetor.tk:666
>
>
>

郑朋飞

unread,
Feb 16, 2011, 8:27:22 AM2/16/11
to sh...@googlegroups.com
在crontab 里判断uptime 行不行?
Startup Applications Preferences_017.png
Login Screen Settings_018.png

znetor

unread,
Feb 16, 2011, 11:51:27 AM2/16/11
to sh...@googlegroups.com
了解了 下次改附件...

伊现富

unread,
Feb 16, 2011, 7:21:11 PM2/16/11
to sh...@googlegroups.com
我主要是想在系统完全启动之后的一定时间之后再运行某个程序。

源泉星火(张明源)

unread,
Feb 16, 2011, 7:50:37 PM2/16/11
to sh...@googlegroups.com
echo 'sleep 60s;command' >> /etc/rc.local
--
明源
http://www.Linuxzh.org
Twitter: @muxueqz

陈若涵

unread,
Feb 16, 2011, 10:16:20 AM2/16/11
to sh...@googlegroups.com
我觉得还是用文件配置的方式靠谱。。这样重装不费心,,只要平时就管理好哪些配置文件,,重装时候就把配置文件放回他该出现的地方就好了


-----------
悲观的思考,乐观的生活.我们既需要思考的深度,也需要生活的温度!



2011/2/16 znetor <zne...@gmail.com>
Login Screen Settings_018.png
Startup Applications Preferences_017.png

znetor

unread,
Feb 16, 2011, 9:32:23 PM2/16/11
to sh...@googlegroups.com
echo 'sleep 60s;command' >> /etc/rc.local


在GUI中也可以 加入sleep 60 达到同样效果 
Startup Applications Preferences_017.png
Login Screen Settings_018.png

伊现富

unread,
Feb 16, 2011, 11:08:18 PM2/16/11
to sh...@googlegroups.com
好的,谢谢各位的建议!

在 11-2-17,znetor<zne...@gmail.com> 写道:


> echo 'sleep 60s;command' >> /etc/rc.local
>
>
> 在GUI中也可以 加入sleep 60 达到同样效果
>
> 在 2011年2月16日 下午11:16,陈若涵 <crha...@gmail.com>写道:
>
>> 我觉得还是用文件配置的方式靠谱。。这样重装不费心,,只要平时就管理好哪些配置文件,,重装时候就把配置文件放回他该出现的地方就好了
>>
>>
>> -----------
>> 悲观的思考,乐观的生活.我们既需要思考的深度,也需要生活的温度!
>>
>>
>>
>> 2011/2/16 znetor <zne...@gmail.com>
>>
>> 有GUI 就尽量用嘛 哈哈~
>>>
>>> 在 2011年2月16日 下午9:10,duxiu xiang <xiangd...@gmail.com>写道:
>>>
>>> 对啊~
>>>>
>>>> 在 2011年2月16日 下午9:08,znetor <zne...@gmail.com>写道:
>>>>
>>>> 你指自动登录吗?
>>>>> 在 system -> administration -> login screen
>>>>>
>>>>> [image: Login Screen Settings_018.png]
>>>>> 在 2011年2月16日 下午9:05,duxiu xiang <xiangd...@gmail.com>写道:
>>>>>
>>>>> 可是Linux开机怎么自动输入账号密码?
>>>>>>
>>>>>> 在 2011年2月16日 下午9:03,znetor <zne...@gmail.com>写道:
>>>>>>
>>>>>> 如果你用ubuntu 的话 用这个玩意吧
>>>>>>>
>>>>>>> 在 System -> Preferences -> Startup Applications ...
>>>>>>>
>>>>>>>
>>>>>>> [image: Startup Applications Preferences_017.png]
>>>>>>>
>>>>>>> 在 2011年2月16日 下午8:54,伊现富 <yixf...@gmail.com>写道:
>>>>>>>
>>>>>>>> 我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
>>>>>>>> 谢谢!
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>

>>>>>>> http://znetor.tk:666
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> 笑看嫣红染半山,逐风万里白云间。
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> http://znetor.tk:666
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> 笑看嫣红染半山,逐风万里白云间。
>>>>
>>>
>>>
>>>
>>> --
>>>

>>> http://znetor.tk:666
>>>
>>>
>>>
>>
>
>
> --
>
> http://znetor.tk:666
>

xiaoyong

unread,
Feb 17, 2011, 12:24:40 AM2/17/11
to sh...@googlegroups.com
GUI 的这个是登录后执行,LZ 要开机自动执行,还是 rc.local 更靠谱。
--
xiaoyong
http://xiaoyong.org/

Startup Applications Preferences_017.png
Login Screen Settings_018.png

伊现富

unread,
Feb 17, 2011, 1:55:47 AM2/17/11
to sh...@googlegroups.com
都可以。我的目的是系统启动项目加载完成后的一段时间之后运行一个程序。

在 11-2-17,xiaoyong<sola...@gmail.com> 写道:

>>>>>>>> http://znetor.tk:666
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 笑看嫣红染半山,逐风万里白云间。
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> http://znetor.tk:666
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 笑看嫣红染半山,逐风万里白云间。
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>

>>>> http://znetor.tk:666
>>>>
>>>>
>>>>
>>>
>>
>>
>> --

ian yang

unread,
Feb 17, 2011, 2:35:19 AM2/17/11
to sh...@googlegroups.com
这个需要登录到gnome-session才运行,而且是登录一次运行一次

2011/2/16 znetor <zne...@gmail.com>
如果你用ubuntu 的话  用这个玩意吧

在 System -> Preferences -> Startup Applications ...

[img]


ian yang

unread,
Feb 17, 2011, 2:39:04 AM2/17/11
to sh...@googlegroups.com
crontab用个特殊的@reboot可以用来在crontab的daemon启动时候执行一次,因为一般crontab的daemon很少重启,可以等同于机器启动时执行

http://en.wikipedia.org/wiki/Cron

2011/2/16 伊现富 <yixf...@gmail.com>
我想在开机后的1分钟启动某个程序,不知道在crontab中如何设置?
谢谢!

伊现富

unread,
Feb 17, 2011, 2:55:31 AM2/17/11
to sh...@googlegroups.com
试过@reboot了,没成功,不知道为什么。

在 11-2-17,ian yang<doit...@gmail.com> 写道:

ian yang

unread,
Feb 17, 2011, 3:14:57 AM2/17/11
to sh...@googlegroups.com
很多系统默认的 /etc/rc.local 最后一行是 exit 0,这样弄是执行不到的

rc.local里的命令是同步执行的,如果不要启动等待最后放到后台去

sleep 60 && command &

2011/2/17 源泉星火(张明源) <zhangmin...@gmail.com>

echo 'sleep 60s;command' >> /etc/rc.local



--
Sincerely, Ian Yang

小马xiaoma

unread,
Feb 17, 2011, 3:38:40 AM2/17/11
to sh...@googlegroups.com
启动项目加载完成的定义是什么?

伊现富

unread,
Feb 17, 2011, 5:17:19 AM2/17/11
to sh...@googlegroups.com
就是说一切系统项目都准备完毕,可以正常使用系统了;然后等待60秒,执行某个程序。

在 11-2-17,小马xiaoma<cnxi...@gmail.com> 写道:

xiaoyong

unread,
Feb 17, 2011, 5:50:06 AM2/17/11
to sh...@googlegroups.com
那到底是开机完成还是登录完成嘛 ==

前者用 rc.local 或者 init script,后者用 .bash_profile/.profile/.bashrc 或者那个 startup applications。

小马xiaoma

unread,
Feb 17, 2011, 7:07:11 AM2/17/11
to sh...@googlegroups.com
由谁去判断可以正常使用系统?

在 2011年2月17日 下午6:17,伊现富 <yixf...@gmail.com> 写道:

源泉星火(张明源)

unread,
Feb 17, 2011, 8:26:37 AM2/17/11
to sh...@googlegroups.com
理解就好。
作为debian用户,我深知/etc/rc.local默认最后一行是exit 0……

伊现富

unread,
Feb 17, 2011, 10:30:09 AM2/17/11
to sh...@googlegroups.com
没这么复杂吧。估计是我说的不清楚,导致大家理解错了。其实就是显示桌面后的一段时间之后执行某个程序。

kyo

unread,
Feb 17, 2011, 7:21:13 PM2/17/11
to Shanghai Linux User Group
如果是基于 gnome 的图形界面. 在 ~/.config/autostart 中添加文件即可. 如:

[Desktop Entry]
Type=Application
Exec=delay 10s chrome
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=chrome
Name=chrome
Comment[en_US]=chrome-google
Comment=chrome-google

重点在于 delay 10s 这个命令, 用以指定在进行桌面多久后执行程序


On Feb 17, 11:30 pm, 伊现富 <yixf1...@gmail.com> wrote:
> 没这么复杂吧。估计是我说的不清楚,导致大家理解错了。其实就是显示桌面后的一段时间之后执行某个程序。
>

> 在 2011年2月17日 下午9:26,源泉星火(张明源) <zhangmingyuan...@gmail.com>写道:
>
>
>
>
>
>
>
> > 理解就好。
> > 作为debian用户,我深知/etc/rc.local默认最后一行是exit 0......


>
> > 在 2011年2月17日 下午4:14,ian yang <doit....@gmail.com>写道:
>
> > 很多系统默认的 /etc/rc.local 最后一行是 exit 0,这样弄是执行不到的
>
> >> rc.local里的命令是同步执行的,如果不要启动等待最后放到后台去
>
> >> sleep 60 && command &
>

> >> 2011/2/17 源泉星火(张明源) <zhangmingyuan...@gmail.com>

陈若涵

unread,
Feb 17, 2011, 10:51:22 AM2/17/11
to sh...@googlegroups.com
。。我有个差不多的问题,我是希望启动的时候运行autossh,但是放在rc.local中不能成功运行,搞不懂为什么,何解?


-----------
悲观的思考,乐观的生活.我们既需要思考的深度,也需要生活的温度!



2011/2/17 伊现富 <yixf...@gmail.com>

long Bill

unread,
Feb 17, 2011, 8:22:33 PM2/17/11
to sh...@googlegroups.com
因目前桌面系统多采用  NetworkManager 管理网络接口。
rc.local 执行时,系统尚无可用的网络链接,所以不成功。

ghosTM55

unread,
Feb 17, 2011, 8:36:47 PM2/17/11
to sh...@googlegroups.com
2011/2/18 kyo <zhouz...@gmail.com>:

> [Desktop Entry]
> Type=Application
> Exec=delay 10s chrome
> Hidden=false
> NoDisplay=false
> X-GNOME-Autostart-enabled=true
> Name[en_US]=chrome
> Name=chrome
> Comment[en_US]=chrome-google
> Comment=chrome-google
>
> 重点在于 delay 10s 这个命令, 用以指定在进行桌面多久后执行程序

学习了~

--
Thomas
Shanghai Linux User Group

http://www.ghosTunix.org
Twitter: @ghosTM55

伊现富

unread,
Feb 17, 2011, 8:40:27 PM2/17/11
to sh...@googlegroups.com
就是需要这个,谢谢了!
delay 10s!!

2011/2/18, ghosTM55 <ghost...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages