我有下面的脚本。
#!/bin/bash
if [ "$EUID" -ne 0 ]
then
echo ''
echo -e "\e[1;31m Please run the script as root \e[0m"
echo ''
exit
fi
for run in {1..11}
do
echo -e '\e[1;32m Initializing AP in backfround... \e[0m'
sudo screen -dmS hot
我的shell脚本如下:
#!/bin/bash
./process1 #It will create a sub process: sub_process1
while [ condition ]; do
break
done
kill -9 process1 and sub_process1
在我的脚本中,它将创建一个进程: process1。process1将创建一个子进程: sub_process1。
在脚本完成之前,它需要杀死process1和sub_process1。
很容易杀死process1,因为它会将PID写入文件中。但sub_process1不会。由于sub_p
我正试图在我的gitlab服务器上启动一个节点服务器。我已经设置了我的gitlab-ci.yml文件,看起来一切正常。但是,我想在测试运行完成后终止节点服务器。
我的gitlab-ci.yml文件的相关部分如下所示:
unit_tests:
stage: test
variables:
GIT_STRATEGY: clone
script:
- npm install
- npm run websocket-server
- npm test
after_script:
- //what should go here to kill
我有一个/tmp/bash.sh,它包含这样一个脚本:
killall name*
如果我转到/tmp文件夹,然后运行./bash.sh,它可以很好地工作,但是如果我转到/,那么运行/tmp/bash.sh或./tmp/bash.sh就不起作用了。相反,它抱怨说
name*: no process found
为什么?怎么解决这个问题?
我所需要的是,铬在任何时候都要关闭,只要x屏幕保护程序清除屏幕(酒店的公共终端,人们对自己的个人安全非常松懈)。附件是我在xscreensaver命令的手册页中找到的一个脚本。
#!/usr/bin/perl
my $blanked = 0;
open (IN, "xscreensaver-command -watch |");
while () {
if (m/^(BLANK|LOCK)/) {
if (!$blanke
我使用Jenkins进行构建,使用插件将我的工件部署到服务器。部署文件后,我通过调用插件中的eec停止了服务
sudo service myservice stop
我在SSH上收到了Publish的回复:
SSH: EXEC: channel open
SSH: EXEC: STDOUT/STDERR from command [sudo service myservice stop]...
SSH: EXEC: connected
Stopping script myservice
SSH: EXEC: completed after 200 ms
SSH: Disconnecting c
如何杀死shell脚本生成的所有进程?myscript多次运行并创建了不想要的进程,我想要杀死它们。我正在运行一个Ubuntu 20。
123 sh /usr/local/bin/myscript /mnt/local/data_file/data1.txt
312 sh /usr/local/bin/myscript /mnt/local/data_file/data1.txt
452 sh /usr/local/bin/myscript /mnt/local/data_file/data1.txt
455 sh /usr/local/bin/myscript /mnt/local/
假设我想杀死firefox,我只需编写pidof fi(按下选项卡)refox(自动显示),然后在终端上写pidof‘给出的’杀死'id。
我知道我可以写“杀死pidof firefox”,但是自动完成不起作用。所以我想要一个命令,比如我的杀死火狐(在这个选项卡上也可以完成),它在后台运行‘杀死pidof firefox’。
我的进程名(带有选项卡完成) -> pidof process name