Git post-commit hook as a background task

不打扰是莪最后的温柔 提交于 2019-11-29 13:22:48

Here's how it works for me:

#!/bin/sh
# I am a post-commit hook
nohup /usr/local/bin/my_script &>/dev/null &

You could also use the at command. You may have to install it first

echo /path/to/your/executable | at now

OR:

echo bash /path/to/your/script | at now

See the at(1) manual page for more info about at (man at or the online version)

Try to use nohup

#!/bin/sh
# I am a post-commit hook
nohup /usr/local/bin/my_script &

If you change #!/bin/sh to #!/bin/bash (assuming you're ok with using bash), and use nohup, your example should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!