Linux中的Linux运行过程 [英] Linux run process in BG

查看:119
本文介绍了Linux中的Linux运行过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



以下是我的代码;



echo输入时间

读取fname1



睡眠fname1&



echo有美好的一天




我需要在这个过程中睡觉这段时间,这个时间取自后台的用户(fname1)。当我尝试使用上面的代码时,它没有正确执行。它会跳过睡眠和背景。



你能不能帮我解决这个问题。



谢谢。

Hello All,

Following is my code;

echo "Enter time"
read fname1

sleep fname1 &

echo "have a nice day"


I need to sleep this process for such amount of time which taken from user (fname1) in background. when I try using above code it didn't execute properly. It skips the sleep and background.

Could you please help me to solve this.

Thank you.

推荐答案

这个任务对我来说听起来没有意义。

在后台运行一个进程意味着:

stell将该命令作为后台进程启动(触发并忘记)并立即继续执行下一个命令



即这立刻就完成了:

The task sounds non-sense to me.
Running a process in background means:
the stell starts that command as background process (fire and forget) and immediately continues with the next command.

I.e. this completes instantly:
sleep 100 &
echo "done"





您可以观察 sleep 流程通过运行 ps 命令。

干杯

Andi



PS:在你的情况下,在背景中是无意义的。离开&

PPS:如果你想让睡眠和回声进入一个后台进程,请执行以下操作:

读取-p输入秒数:秒; (睡眠



You may observe the sleep process by running the ps command.
Cheers
Andi

PS: In your case, the "in background" is non-sense. Leave away the &.
PPS: If you want the sleep and the echo go into one background process, do this:
read -p "Enter seconds: " sec; (sleep


sec; echo度过愉快的一天)&
sec; echo "have a nice day") &.


这篇关于Linux中的Linux运行过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆