我想在打开任何应用程序之前通过 bash 脚本执行某些操作,例如。firefox/deluge/VLC 通过 GUI 或 CLI。该脚本应该只为某些应用程序而不是所有应用程序执行。如何做到这一点?
我写了一个简单的 bash 脚本:
#!/bin/bash
echo "hi" > log
exit 0
Run Code Online (Sandbox Code Playgroud)
使其可执行并成功运行。我将 rc.local 编辑为以下内容:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/katph/test.sh
exit 0
Run Code Online (Sandbox Code Playgroud)
rc.local 是可执行的:
/$ ls …Run Code Online (Sandbox Code Playgroud) 我在开发机器上安装了这 2 个网络服务器,因为它们都绑定到端口 80,在任何给定时间只有一个可以运行。
我希望能够修改 init 启动过程,以便我可以选择启动哪一个,禁用哪一个。
为了知道我需要做什么来实现这一点,我试图找出实际控制这些服务启动的因素。
我的理解是 Ubuntu 14.04 启动脚本由 Upstart 处理,并且 upstart init 脚本在/etc/init.
但是 nginx 中没有nginx.conf条目,/etc/init而是有一个条目/etc/init.d- 这是否意味着 Nginx 由 SysV 而不是 Upstart 管理?
这是否也意味着默认情况下 Ubuntu 14.04(在 15.04 上迁移到 systemd 之前)可能使用 upstart 和 initV 的组合?
还是重要的系统进程只由 Upstart 启动,而像 Nginx 这样的单个软件包可能会选择 upstart 或 systemV init?
我只是想问,是否有任何方法可以创建登录后显示的错误消息,以及是否可以将其与脚本结合起来检查 Internet 连接。
我已经阅读了有关的各种问题,how to run script at startup但我不太确定有什么区别,以及没有 GUI 的实际正确方法是什么。
/etc/rc.local@reboot~/.profile/.bash_profile/.bash_login我需要在启动时运行的示例
apt-get updatesudo即使主脚本已经以 root 身份执行,我是否应该调用它们?)最好有一个单一的脚本来处理一个文件中的所有这些事情。如何正确操作?
我对 ubuntu 很陌生。我想在系统启动并打开桌面屏幕后立即自动打开终端。我怎样才能做到这一点?
我仅将FortiClient用于 VPN 目的,其他时间不需要它运行。我无法从启动时开始禁用。如何在启动时禁用 FortClient 的自动启动?
问题:哪些机制(除了 in /etc/fstab)fsck在启动时自动触发?
详细信息:我的电脑目前运行 Ubuntu 21.04没有任何问题,它工作正常。在启动时,fsck会执行磁盘检查,因为我在屏幕上看到以下几行。
Ubuntu: clean, 281400/3276800 files, 3602929/13107177 blocks
Run Code Online (Sandbox Code Playgroud)
Ubuntu我的/dev/sda2(根分区)的标签在哪里。但是,如果您检查我的/etc/fstab文件,最后一列(即 fsck 用于确定 fsck 是否应在挂载之前检查文件系统的列)设置为零,因此我不希望在启动时进行任何检查。
# <file system> <mount point> <type> <options> <dump> <pass>
# /dev/sda1
UUID=DA59-E469 /boot/efi vfat defaults 0 0
# /dev/sda2
UUID=862c6f26-cbe0-4cd5-860d-fdf306f697f9 / ext4 noatime,errors=remount-ro 0 0
# /dev/sda3
UUID=70f175d4-ec37-455c-84c5-b93d1e2e8761 /mnt/Data ext4 noatime,nosuid,nodev,nofail,x-gvfs-show 0 0
# swapfile
/swapfile none swap sw 0 0
Run Code Online (Sandbox Code Playgroud)
我只是想知道检查是如何触发的(和/或我的假设是否有问题)。
一些细节:
/etc/fstab在 Ubuntu 20.04 和 …Ubuntu 版本:22.04.1 LTS 嘿!我正在尝试startup.sh在/root/startup.sh启动时运行。这是文件的内容:
synclient VertScrollDelta=-100
synclient CoastingFriction=35
synclient MinSpeed=0.05
synclient MaxSpeed=0.7
echo "All went according to plan..."
Run Code Online (Sandbox Code Playgroud)
当我使用手动运行文件时sudo /root/startup.sh,一切都会按计划进行,但是在我在键入以下内容时打开的内容中写入以下行之后crontab -e:
@reboot root sh /root/startup.sh >/dev/null 2>&1
并重新启动我的计算机,什么也没发生。我尝试在这里使用这个答案,并评论你必须在 ubuntu 上做什么。
有人知道如何解决这个问题吗?
日志:
Jan 17 11:04:10 sexy-cat-girl-computer CRON[1015]: (originalusernamelol) CMD (root sh /root/startup.sh >/dev/null 2>&1)
Run Code Online (Sandbox Code Playgroud)
并且只有@reboot root sh /root/startup.sh:
Jan 17 11:01:34 sexy-cat-girl-computer CRON[1026]: (originalusernamelol) CMD (root sh /root/startup.sh)
Jan 17 11:01:34 sexy-cat-girl-computer CRON[976]: (CRON) info (No MTA installed, …Run Code Online (Sandbox Code Playgroud)