我已经知道真正的用户ID.它是系统中用户的唯一编号.在我的系统中,My uid是
$ echo $UID
1014
$
Run Code Online (Sandbox Code Playgroud)
另外两个ID代表什么?什么是有效用户ID和保存的用户ID的使用以及我们在系统中使用它的位置.
与标题相同:如何Rails.logger在运行rspec时打印到控制台/标准输出?例如.
Rails.logger.info "I WANT this to go to console/stdout when rspec is running"
puts "Like how the puts function works"
Run Code Online (Sandbox Code Playgroud)
我还是希望Rails.logger去log/test.log了.
我有以下内容.
tail -f成功消息的命令检查日志文件.即使我在代码中有0出口,我也无法结束这个tail -f过程.
哪个不让我的脚本完成.在Bash中有没有其他方法可以做到这一点?
代码如下所示.
function startServer() {
touch logfile
startJavaprocess > logfile &
tail -f logfile | while read line
do
if echo $line | grep -q 'Started'; then
echo 'Server Started'
exit 0
fi
done
}
Run Code Online (Sandbox Code Playgroud) 请考虑以下简化示例:
my_prog|awk '...' > output.csv &
my_pid="$!" #Gives the PID for awk instead of for my_prog
sleep 10
kill $my_pid #my_prog still has data in its buffer that awk never saw. Data is lost!
在bash中,$my_pid指向PID awk.但是,我需要PID my_prog.如果我杀了awk,my_prog不知道要刷新它的输出缓冲区并且数据丢失了.那么,如何获得PID my_prog呢?请注意,ps aux|grep my_prog由于可能会有几个工作,因此无法使用my_prog.
注意:更改cat为awk '...'帮助澄清我需要的内容.
(或如何杀死子进程)?
inotifywait -mqr --format '%w %f %e' $feedDir | while read dir file event
do
#something
done &
echo $! #5431
Run Code Online (Sandbox Code Playgroud)
ps例如:
>$ ps
PID TTY TIME CMD
2867 pts/3 00:00:02 bash
5430 pts/3 00:00:00 inotifywait
5431 pts/3 00:00:00 bash
5454 pts/3 00:00:00 ps
Run Code Online (Sandbox Code Playgroud)
看来,如果我杀死5431,则5430(inotifywait)将保持运行,但是如果我杀死5430,则两个进程都将死亡。我想我不能可靠地假设inotifywait的pid 总是比$小1!?