Git post-commit hook as a background task

前端 未结 4 1868
情书的邮戳
情书的邮戳 2020-12-20 11:11

I have a script, that I need to run after committing to a project under git revision control. Therefore I created a post-commit hook in my projects .git directory in the sub

相关标签:
4条回答
  • 2020-12-20 11:36

    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)

    0 讨论(0)
  • 2020-12-20 11:44

    Try to use nohup

    #!/bin/sh
    # I am a post-commit hook
    nohup /usr/local/bin/my_script &
    
    0 讨论(0)
  • 2020-12-20 11:50

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

    0 讨论(0)
  • 2020-12-20 11:52

    Here's how it works for me:

    #!/bin/sh
    # I am a post-commit hook
    nohup /usr/local/bin/my_script &>/dev/null &
    
    0 讨论(0)
提交回复
热议问题