我编写了一个小的shell脚本,它为i3;Arch中的视频背景启动一个mplayer实例。现在,我想每15秒杀死这个过程,然后重新启动它。但是,由于这个背景将一直运行,所以使用名称杀人会导致"iCantUseMplayerAnymorePlzHelp“,那么,我如何才能扼杀这个过程呢?
对于bg,我执行以下操作:
mplayer -loop 0 -rootwin -ao null -noconsolecontrols -fs VIDEOPATH发布于 2018-03-17 12:38:26
如果您想要启动mplayer,15秒后关闭它,然后重复直到脚本本身被杀死,您可以这样做:
#!/bin/sh
while true; do
## launch mplayer in the background
mplayer -loop 0 -rootwin -ao null -noconsolecontrols -fs VIDEOPATH &
## wait for 15 seconds
sleep 15
## kill the 1st backgrounded job of this subshell
kill %1
donehttps://unix.stackexchange.com/questions/430749
复制相似问题