Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当网络连接时,我想在 Ubuntu 上运行一个脚本。主要目的应该是在第一次连接到 Internet 后立即更新时间。
我知道/etc/network/if-up.d/应该执行来自的脚本。只需在此文件夹中放置一个脚本
/etc/network/if-up.d/
date -u > /tmp/test.time
未执行原因/tmp/不显示任何test.time. 我不知道这是否有影响,但我配置了一个静态 IP 地址。
/tmp/
test.time
所以我的问题是当建立到 Internet 的连接时如何执行脚本(resp。命令)?以及如何安装它以在启动后运行?
看看 Upstart:http ://upstart.ubuntu.com/ 您可以将脚本连接到各种系统事件。他们的文档解释了这一切。我认为您需要net-device-up事件,请在文档中查找。
net-device-up