I faced a strange behaviour. First, I setup cron jobs as described in http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-cron.html. Then I changed file permissions to dev mode (writeable). When cron jobs have started, files were being deleted. As soon as I noticed this, I changed file permissions back to recommended for production mode and files stopped disappering.
Cron Daemon email (Subject: Cron /usr/bin/php /home/[my-domain]/public_html/update/cron.php):
..........
PHP Warning: unlink(/home/[my-domain]/public_html/[my-domain]/.git/hooks/post-update.sample): Permission denied in /home/[my-domain]/public_html/update/app/code/Magento/Update/Rollback.php on line 157
PHP Warning: rmdir(/home/[my-domain]/public_html/[my-domain]/.git/hooks): Permission denied in /home/[my-domain]/public_html/update/app/code/Magento/Update/Rollback.php on line 155
...........
/var/log/update.log:
[2017-03-23 17:00:03] update-cron.INFO: Job "rollback {"backup_file_name":"/home/[my-domain]/public_html/var/backups/1480414203_filesystem_code.tgz"}" has been started [] []
[2017-03-23 17:00:03] update-cron.INFO: Restoring archive from "/home/[my-domain]/public_html/var/backups/1480414203_filesystem_code.tgz" ... [] []
[2017-03-23 17:00:49] update-cron.INFO: An error occurred while executing job "rollback {"backup_file_name":"/home/[my-domain]/public_html/var/backups/1480414203_filesystem_code.tgz"}": Extraction from phar "/home/[my-domain]/public_html/var/backups/1480414203_filesystem_code.tar" failed: Cannot extract "app/code/CustomerParadigm/OrderComments/view/frontend/requirejs-config.js", could not open for writing "/home/[my-domain]/public_html/app/code/CustomerParadigm/OrderComments/view/frontend/requirejs-config.js" [] []
[2017-03-23 17:00:49] update-cron.INFO: Job "rollback {"backup_file_name":"/home/[my-domain]/public_html/var/backups/1480414203_filesystem_media.tgz"}" has been started [] []
[2017-03-23 17:00:49] update-cron.INFO: Restoring archive from "/home/[my-domain]/public_html/var/backups/1480414203_filesystem_media.tgz" ... [] []
[2017-03-23 17:01:00] update-cron.INFO: Job "rollback {"backup_file_name":"/home/[my-domain]/public_html/var/backups/1480414203_filesystem_media.tgz"}" has successfully completed [] []
Crontab (disabled for now):
# @hourly /usr/bin/php /home/[my-domain]/public_html/update/cron.php%/home/[my-domain]/public_html/var/log/update.cron.log #Magento cron (2)
# @hourly /usr/bin/php /home/[my-domain]/public_html/bin/magento cron:run | grep -v "Ran jobs by schedule"%/home/[my-domain]/public_html/var/log/magento.cron.log #Magento cron (1)
# @hourly /usr/bin/php /home/[my-domain]/public_html/bin/magento setup:cron:run%/home/[my-domain]/public_html/var/log/setup.cron.log #Magento cron (3)
Why have files start being deleted? How to prevent from it in future?