pkr
September 21, 2020, 8:25pm
1
I have created a cronjob to run Rsync. The permissions for the file that I am using for cronjob is as follows:
-rwxrwxr-x 1 root root 891 Sep 18 09:51 v-user-rsync-alldata
If I run it on the command line using “bash v-user-rsync-alldata”, it works as expected. However, when I added a cron job thru the HestiaCP to automate it, the cronjob did not run. Is there anything else that I am missing in setting up a new cronjob? The default cronjobs that come with HestiaCP installtion are working as expected.
1 Like
eris
September 21, 2020, 8:28pm
2
Use full path for example
sudo /usr/local/hestia/bin/v-update-letsencrypt-ssl
pkr
September 21, 2020, 8:49pm
3
I have used this:
sudo /usr/local/usercron/v-user-rsync-alldata
eris
September 21, 2020, 8:54pm
4
admin user have only access to
sudo is limited to hestia scripts
admin ALL=NOPASSWD:/usr/local/vesta/bin/*
admin ALL=NOPASSWD:/usr/local/hestia/bin/*
pkr
September 21, 2020, 9:11pm
5
Thank you.
I moved my files to /usr/local/hestia/bin/ and it’s working now.
1 Like
eris
September 21, 2020, 9:29pm
6
You could also add a line to /etc/sudoers.d/admin
1 Like
alex7
February 16, 2023, 11:23am
7
secure way:
set cron task php script running without sudo:
/usr/bin/php /home/admin/web/.../cron.php
insecure way:
> visudo /etc/sudoers.d/admin
add line:
admin ALL=NOPASSWD:/usr/bin/php
save
test:
login as admin:
> sudo su -l admin -s /bin/bash
start cron task :
> sudo /usr/bin/php /home/admin/web/.../cron.php
test2 monitor cron log:
> journalctl -f -u cron
eris
February 16, 2023, 11:59am
8
Please don’t do that. You should not run any websites under a users that is able to run as root
2 Likes