I'm using Ubuntu 16.04.1 LTS. I have installed incron and added root to incron.allow.
Normally I use sudo incrontab -e
to add an incron job with the editor.
I need a command which can be run from a script which will add this line to the incrontab directly:
/home/ci-server/DB_Backups IN_MOVED_TO mv /home/ci-server/DB_Backups/$# /home/backup/$#
Once this line is shown via sudo incrontab -l
everything should be good to go.
I have found a couple of examples using cron but very little information exists for incron.
You can do this by creating a script named incron.sh
with the following contents:
#create a new file named incron.txt that lists the incron job
sudo echo '/home/ci-server/DB_Backups IN_MOVED_TO mv /home/ci-server/DB_Backups/$# /home/backup/$#' > /home/ci-server/scripts/incron/incron.txt
#add the job(s) listed in our newly created incron.txt to the incrontab
sudo incrontab -u root /home/ci-server/scripts/incron/incron.txt