Cron Job failing with no TTY present
Posted: Mon May 28, 2018 2:45 pm
I am working on a custom backup script that will move the vesta built backups to a remote windows server. I know its a little odd but its what I have. The share "/cifs" is mounting fine and accessible. I have built the script to check to make sure the mount is active and if not then mount the drive and creates a log entry. Once mounted it copies the backup files over but only the new ones. It then removes any backups that over 7 days. This script requires Sudo. I have tested and verified that the script runs fine in SSH, but does prompt for a password. I have added it to the Cron section on admin user in VestaCP but it keeps failing with sudo: no tty present and no askpass program specified.
The Server is VestaCP built on CentOS 7.
Here is the Script located in /etc/scripts
Here is my sudoers.d/admin file
Does any one have any suggestions on this issue?
The Server is VestaCP built on CentOS 7.
Here is the Script located in /etc/scripts
Code: Select all
#!/bin/bash
#start
#-----------------------------------------------------------------------
dt=$(date '+%d/%m/%Y %H:%M:%S');
if [[ $(findmnt "/cifs") ]]; then
echo $dt" Mounted" >> /var/log/cifs_mount.log
else
echo $dt" Not mounted" >> /var/log/cifs_mount.log
mount -a
fi
cp -u /backup/* /cifs/daily/users
find /cifs/daily/users/ -name '*.tar' -mtime +7 | xargs rm -f;
find /cifs/fullsystem/ -name '*.gz' -mtime +30 | xargs rm -f;
# Are Weekly Backups Implemented?
# find /srv/backup/weekly/ -name '*.gz' -mtime +14 | xargs rm -f;
#-----------------------------------------------------------------------
#end
Code: Select all
# Created by vesta installer
Defaults env_keep="VESTA"
Defaults:admin !syslog
Defaults:admin !requiretty
Defaults:root !requiretty
admin ALL=(ALL) ALL
admin ALL=NOPASSWD:/usr/local/vesta/bin/*, /etc/scripts/*
- I have tested from SSH, Script works fine but requires a password.
- I have added /etc/scripts/* to the sudoers.d/admin file. and updated the Cron Tab of VestaCP No avail.
- I have moved a copy to /usr/local/vesta/bin/* and added that location to the Cron Tab on VestaCP no avail. all other sudo scripts in the /usr/local/vesta/bin/* run with no issues.
- I have verified permissions are set to 755 and root:root like all the other scripts in /usr/local/vesta/bin/*.
- I have intentionally and temporary commented "Defaults:admin !requiretty" no avail.
Does any one have any suggestions on this issue?