User Cronjob does not work

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

Use full path for example

sudo /usr/local/hestia/bin/v-update-letsencrypt-ssl

I have used this:

sudo /usr/local/usercron/v-user-rsync-alldata

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/*

Thank you.
I moved my files to /usr/local/hestia/bin/ and it’s working now.

1 Like

You could also add a line to /etc/sudoers.d/admin :slight_smile:

1 Like
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 

Please don’t do that. You should not run any websites under a users that is able to run as root

2 Likes