Page 1 of 1

Cron job not running

Posted: Wed Apr 11, 2018 8:43 am
by HenrysCat
I have searched this forum and tried many solutions but I just can't get it to work.

I have a script here /home/admin/web/mydomain/public_html/rclone-cron.sh as below to use rclone to backup to Backblaze

Code: Select all

    #!/bin/bash

    if pidof -o %PPID -x "rclone-cron.sh"; then
    exit 1
    fi
    rclone sync /home/admin/web/mydomain/public_html/ remote:bucket
    exit
If I run

Code: Select all

/home/admin/web/mydomain/public_html/rclone-cron.sh
from a terminal (logged in as admin) the backup runs no problem.

Howver I cannot get it to run in cron, command as below,

Code: Select all

sudo /home/admin/web/mydomain/public_html/rclone-cron.sh
I have checked the cron log in /var/log and find the lines,

Code: Select all

Apr 11 06:00:01 vultr CROND[6886]: (admin) CMD (sudo /home/admin/web/mydomain/public_html/rclone-cron.sh
But no backup perfomed, only when I run the command from a terminal does the backup run.
Any ideas?

Re: Cron job not running

Posted: Wed Apr 11, 2018 9:19 am
by yoko eagle
HenrysCat wrote:
Wed Apr 11, 2018 8:43 am
I have searched this forum and tried many solutions but I just can't get it to work.

I have a script here /home/admin/web/mydomain/public_html/rclone-cron.sh as below to use rclone to backup to Backblaze

Code: Select all

    #!/bin/bash

    if pidof -o %PPID -x "rclone-cron.sh"; then
    exit 1
    fi
    rclone sync /home/admin/web/mydomain/public_html/ remote:bucket
    exit
If I run

Code: Select all

/home/admin/web/mydomain/public_html/rclone-cron.sh
from a terminal (logged in as admin) the backup runs no problem.

Howver I cannot get it to run in cron, command as below,

Code: Select all

sudo /home/admin/web/mydomain/public_html/rclone-cron.sh
I have checked the cron log in /var/log and find the lines,

Code: Select all

Apr 11 06:00:01 vultr CROND[6886]: (admin) CMD (sudo /home/admin/web/mydomain/public_html/rclone-cron.sh
But no backup perfomed, only when I run the command from a terminal does the backup run.
Any ideas?
replace sudo with /bin/sh or /usr/bin/sh
if still not working try to chmod the file

Code: Select all

chmod +x /home/admin/web/mydomain/public_html/rclone-cron.sh

Re: Cron job not running

Posted: Wed Apr 11, 2018 11:02 am
by HenrysCat
replace sudo with /bin/sh or /usr/bin/sh
if still not working try to chmod the file

Code: Select all

chmod +x /home/admin/web/mydomain/public_html/rclone-cron.sh
Tried both no joy, rclone-cron.sh permissions are 755, as I said it runs manually from terminal logged in as admin, just not in cron.