Page 1 of 2

running a bash script via cron

Posted: Mon Jul 25, 2016 11:42 am
by rkhyd
I added a cron job to run a bash script.
Image

However, it does not run! It runs fine when i execute it manually. I do not see the entry in the cron log either. What could be the issue?

Regards
RK

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 12:29 pm
by imperio
What's errors do you see on your email?
This command runs under admin or another user?
Do you enable bash for admin or another user?

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 12:44 pm
by rkhyd
hello
this is the error i receive via email.
sudo: no tty present and no askpass program specified

This command runs under admin account.

Not sure if bash is enabled for admin. how to check it?

RK

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 12:47 pm
by imperio
On main user page of VestaCP

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 12:51 pm
by rkhyd
yes, the ssh access is set to bash on the admin page.

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 12:57 pm
by imperio
Try to run this command via ssh and publish the result here

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 1:13 pm
by rkhyd
ok, its asking for password of admin
[sudo] password for admin:
Enter the password for admin

Re: running a bash script via cron

Posted: Mon Jul 25, 2016 3:11 pm
by rkhyd
i have searched the internet for the possible solutions.
i added this line to the visudo file
admin ALL=(ALL) NOPASSWD:/bin/bash
but no luck... i am still being prompted for password. please help.

Re: running a bash script via cron

Posted: Tue Jul 26, 2016 6:32 am
by skurudo
How your sudoers look like?
/etc/sudoersShow

Code: Select all

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults        env_keep="VESTA"
Defaults:admin  !requiretty

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Re: running a bash script via cron

Posted: Tue Jul 26, 2016 6:42 am
by rkhyd
here is my sudoers file

Code: Select all

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
%admin  ALL=(ALL)       ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL