0

I have a monit service running.
It checks to see if a file changed, then it fires off a script to make sure that file gets put into git:

check file ncc_db with path /home/ootbdv/ncc_db/production.sqlite3
      if changed checksum then exec "/home/ootbdv/ncc_db/autocommit.sh"

I know that I've setup monit correctly because the log file shows this.

[PDT Jun  3 01:04:14] info     : 'ncc_db' checksum has not changed
[PDT Jun  3 01:10:14] error    : 'ncc_db' checksum was changed for /home/ootbdv/ncc_db/production.sqlite3
[PDT Jun  3 01:10:14] info     : 'ncc_db' exec: /home/ootbdv/ncc_db/autocommit.sh
[PDT Jun  3 01:12:14] error    : 'ncc_db' checksum was changed for /home/ootbdv/ncc_db/production.sqlite3
[PDT Jun  3 01:12:14] info     : 'ncc_db' exec: /home/ootbdv/ncc_db/autocommit.sh
[PDT Jun  3 01:14:14] info     : 'ncc_db' checksum has not changed

So I know that monit is working.
I also know the script is working because, as root, when I type in /home/ootbdv/ncc_db/autocommit.sh the script works as expected, it jumps into the directory and fires off the git command.

The script:

#/bin/bash

cd /home/ootbdv/ncc_db/
git commit -a -m 'monit:autocommit'

Am I doing something wrong such that monit isn't working as expected?

Community
  • 1
  • 1
Son of the Wai-Pan
  • 12,371
  • 16
  • 46
  • 55

2 Answers2

0

Looks like your script is correct but you did not push the added files back to the remote repository.

You added the file to your local repository and now you have to push it to the remote repository

The script:

#/bin/bash

cd /home/ootbdv/ncc_db/
git commit -a -m 'monit:autocommit'
git push <origin_name> <branch_name>
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • I don't need to push it to a remote repository. The local repository is fine. My workaround was just to create this common directly in the monit config file: `check file ncc_db with path /home/ootbdv/ncc_db/production.sqlite3 if changed checksum then exec "/bin/bash -c 'cd /home/ootbdv/ncc_db/;git commit -a -m monit:auto commit'"` – Son of the Wai-Pan Jun 04 '15 at 02:16
0

The problem was that the header in the script was incorrect; it should have read #!/bin/bash instead of #/bin/bash.

Hope this helps someone else.

Son of the Wai-Pan
  • 12,371
  • 16
  • 46
  • 55