Join the community today
Register Now

Bug csfcf.sh and rclone.sh in cronjob in almalinux 8

Discussion in 'AlmaLinux 8 & Rocky Linux 8 Beta Testing' started by Max Chan, May 16, 2023.

  1. Max Chan

    Max Chan New Member

    10
    3
    3
    Feb 17, 2020
    internet
    Ratings:
    +9
    Local Time:
    9:54 PM
    1.25.4
    MariaDB 10.6
    When running those two scripts in cronjob both are not working first the csfcf.sh it will not update ip in csf.ignore and csf.allow i tested it by removing cloudflare ips csf and try run the script in terminal
    Code:
    usr/local/src/centminmod/tools/csfcf.sh auto
    its updates the csf. but when i try using cronjob it dont update the csf ip

    Code:
    cronjob
    22 */12 * * * /usr/local/src/centminmod/tools/csfcf.sh auto >/dev/null 2>&1
    25 4 * * * /usr/local/src/centminmod/addons/rclone.sh copy mega50 >/dev/null 2>&1
     
    i ask ChatGPT and try to solve the problem it recommend me to add this in the script
    Code:
    # Set required environment variables
    export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    It solve the problem the script can update ip in csf again in cronjob.
    same with the rclone its working on terminal but not in cronjob
    Code:
    rclone log
    
    remote = mega50
    
    copy /root/centminlogs to cloud storage remote mega50
    https://community.centminmod.com/posts/39071/
    
    rclone copy /root/centminlogs mega50:scw-shadowking/copy-centminlogs --exclude rclone_copy_160523-042501.log
    /usr/local/src/centminmod/addons/rclone.sh: line 534: rclone: command not found
    
    copy /usr/local/nginx/conf to cloud storage remote mega50
    
    rclone copy /usr/local/nginx/conf mega50:scw-shadowking/copy-nginxconf
    /usr/local/src/centminmod/addons/rclone.sh: line 539: rclone: command not found
    
    
    Total Rclone Copy Time: .002308947 seconds
    
    also i able to solve my rclone problem by editing rclone.sh
    from
    Code:
    rclone_copy() {
      remote=$1
      if [[ -z "$remote" ]]; then
        echo
        echo "incorrect syntax"
        echo "use the following syntax where remote_name"
        echo "is the remote you configured with rclone"
        echo
        echo "$0 copy remote_name"
        exit
      fi
      echo
      echo "copy /root/centminlogs to cloud storage remote $remote"
      echo "https://community.centminmod.com/posts/39071/"
      echo
      echo "rclone copy /root/centminlogs ${remote}:${HOSTDOMAIN}/copy-centminlogs --exclude "rclone_copy_${DT}.log""
      rclone copy /root/centminlogs ${remote}:${HOSTDOMAIN}/copy-centminlogs --exclude "rclone_copy_${DT}.log"
      echo
      echo "copy /usr/local/nginx/conf to cloud storage remote $remote"
      echo
      echo "rclone copy /usr/local/nginx/conf ${remote}:${HOSTDOMAIN}/copy-nginxconf"
      rclone copy /usr/local/nginx/conf ${remote}:${HOSTDOMAIN}/copy-nginxconf
      echo
    }
    
    to
    Code:
    rclone_copy() {
      remote=$1
      if [[ -z "$remote" ]]; then
        echo
        echo "incorrect syntax"
        echo "use the following syntax where remote_name"
        echo "is the remote you configured with rclone"
        echo
        echo "$0 copy remote_name"
        exit
      fi
      echo
      echo "copy /root/centminlogs to cloud storage remote $remote"
      echo "https://community.centminmod.com/posts/39071/"
      echo
      echo "rclone copy /root/centminlogs ${remote}:${HOSTDOMAIN}/copy-centminlogs --exclude "rclone_copy_${DT}.log""
      /usr/sbin/rclone copy /root/centminlogs ${remote}:${HOSTDOMAIN}/copy-centminlogs --exclude "rclone_copy_${DT}.log"
      echo
      echo "copy /usr/local/nginx/conf to cloud storage remote $remote"
      echo
      echo "rclone copy /usr/local/nginx/conf ${remote}:${HOSTDOMAIN}/copy-nginxconf"
      /usr/sbin/rclone copy /usr/local/nginx/conf ${remote}:${HOSTDOMAIN}/copy-nginxconf
      echo
    }


     
  2. eva2000

    eva2000 Administrator Staff Member

    54,113
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    11:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    interesting so for both addons/rclone.sh and tools/csfcsf.sh, if you add export PATH just after 1st line like
    Code (Text):
    #!/bin/bash
    export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
    

    it fixes both scripts on cronjob?
     
  3. Max Chan

    Max Chan New Member

    10
    3
    3
    Feb 17, 2020
    internet
    Ratings:
    +9
    Local Time:
    9:54 PM
    1.25.4
    MariaDB 10.6
    yes in csfcf.sh it fix by adding export path, in rclone.sh since i use copy in my cronjob i edit the
    rclone_copy() replacing rclone copy to /usr/sbin/rclone this one fix my rclone.sh cronjob problem
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,113
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    11:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    the export path should fix rclone.sh too - try and let me know if it does
     
  5. Max Chan

    Max Chan New Member

    10
    3
    3
    Feb 17, 2020
    internet
    Ratings:
    +9
    Local Time:
    9:54 PM
    1.25.4
    MariaDB 10.6
    yes i tested it /usr/sbin/rclone and add that export path and yeah it fix the problem in rclone.sh
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,113
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    11:54 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Great, updated 130.00beta01 with the fixes for some addons and tools which maybe cronjob utilised :)