如何在hibernate之后或之前运行脚本

我想在hibernate之前运行4个命令,在更新之后运行另外2个命令。 是否也可以安排每个命令的时间/顺序,如果是,那么你能解释一下吗?

您可以通过在/etc/pm/sleep.d创建脚本来在hibernate或暂停之前和之后运行命令(注意有区别;hibernate是磁盘,暂停是内存):

 #!/bin/bash case "$1" in hibernate) # put commands to run on hibernation here ;; thaw) # put commands to run when returning from hibernation here ;; suspend) # put commands to run on suspend here ;; resume) # put commands to run when returning from suspension ;; esac 

与sleep.d中的其他脚本相比,脚本的文件名将指示脚本运行的顺序。 在您的脚本中,您的命令将以您在脚本中放置的任何顺序运行。