在Debian中,你可以使用nohup命令结合&符号来实现多任务并行处理
打开终端。
输入以下命令,用nohup在后台运行多个任务:
nohup command1 &
nohup command2 &
nohup command3 &
将command1、command2和command3替换为你想要并行执行的实际命令。&符号会让命令在后台运行,即使你关闭终端,它们也会继续执行。
tail命令:tail -f nohup.out
这将显示nohup.out文件的内容,这是所有后台任务的默认输出文件。如果你想查看特定任务的输出,可以在tail命令中指定相应的输出文件。
mail命令发送通知。首先,确保你的系统已配置好邮件发送功能。然后,使用以下命令:nohup command1 > output1.out 2>&1 &
nohup command2 > output2.out 2>&1 &
nohup command3 > output3.out 2>&1 &
# 在所有任务完成后发送通知
wait && echo "All tasks completed." | mail -s "Task Notification" your_email@example.com
这将把每个任务的输出重定向到不同的文件,并在所有任务完成后发送一封包含通知的电子邮件。请将your_email@example.com替换为你的实际电子邮件地址。
通过这种方式,你可以在Debian中使用nohup命令实现多任务并行处理。