Results 1 to 4 of 4

Thread: Cron & rsync help needed!

Hybrid View

  1. #1
    Join Date
    May 2013
    Beans
    2

    Cron & rsync help needed!

    Hi everyone,

    i have an issue with a cron i have setup, the cron actually works fine as it is supposed to but the main problem is with rsync and the perl script that i am running.

    simply, it just wont get the files from the server, acts much like a backup, except it happens every 10 minutes.

    the script is failing to sync the files from one machine to the other, and i do not know why, i know the script itself works as it will run perfectly through the terminal.

    cron code =
    Code:
    #min    hour    day    month    dow    user        cmd
    */10    *    *    *    *    adscreen    /var/www/cgi-bin/sys/sys_stream.sh
    and the script file =
    Code:
    #!/bin/sh
    
    #IFS=$'\n'
    
    
    streamsconfig='/var/www/data/streams.conf'
    
    
    # check if the config file exists. If not then stop
    [ -e $streamsconfig ] || exit
    
    
    extensions=(.cfg .data .menu)
    
    
    function getanims
    {
        /usr/bin/awk 'BEGIN {
                    FS="|"
                }
                {
                    if ($2 ~ /\^DU/) next
                    for (n=1; n<=NF; n++)
                    if ($n ~ /\.(swf|mov|mpg|mpeg|mp4|avi|flv|wmv|SWF|MOV|MPG|MPEG|MP4|AVI|FLV|WMV)/) print $n
                }' $1
    }
    
    
    function getpics
    {
        /usr/bin/awk 'BEGIN {
                    FS="|"
                }
                {
                    if ($2 ~ /\^DU/) next
                    for (n=1; n<=NF; n++)
                    if ($n ~ /\.(png|jpg|gif|PNG|JPG|GIF)/) print $n
                }' $1
    }
    
    
    conffile=(`cat $streamsconfig`)
    
    
    # process each line of the config file
    for line in ${conffile[@]}; do
    
    
        host=`echo $line | cut -d '|' -f 2`
        show=`echo $line | cut -d '|' -f 3`
    
    
        # create include string for data files
        include_list=""
        for ext in ${extensions[@]}; do
            include_list="$include_list --include=$show$ext"
        done
    
    
        # important to put exclude last
        include_list="$include_list --exclude=*"
    
    
        # retrieve the data files
        rsync -uzr $include_list adscreen@$host:/var/www/data/ /var/www/data/
    
    
        # create include string for anims and images
        include_list="--include=anims --include=images"
    
    
        for ext in ${extensions[@]}; do
            for incl in `getanims /var/www/data/$show$ext | sort -u`; do
                include_list="$include_list --include=anims/$incl"
            done
    
    
            for incl in `getpics /var/www/data/$show$ext | sort -u`; do
                include_list="$include_list --include=images/$incl"
            done
        done
    
    
        # important to put exclude last
        include_list="$include_list --exclude=*"
    
    
        rsync -zcr adscreen@$host:/var/www/html/$show/ /var/www/html/$show/
    done
    can anyone please assist me as i am new to linux stuff

    i have searched high and low through forums etc with no luck as to why it wont run
    Last edited by adscreen; May 10th, 2013 at 08:47 AM.

  2. #2
    Join Date
    Apr 2008
    Location
    England
    Beans
    260
    Distro
    Ubuntu

    Re: Cron & rsync help needed!

    Suggest a good place to start would be to look in the cron log (/var/log/cron.log). I once had something similar and it was as simple as I was running the cron job as the "wrong" user which didn't have sufficient permissions to perform the task.

  3. #3
    Join Date
    May 2013
    Beans
    2

    Re: Cron & rsync help needed!

    the guy that made our software states " Streaming
    Definition:
    Streaming gives you the ability to move the data that comprises a show from one media player to another media player. To achieve this the destination player has to be set up with the steaming software. The source machine requires on extra pieces of software, its only requirement is the show that is to be streamed.
    Software Installation
    Software required:
    • /var/www/cgi-bin/sys/sys_config.cgi
    • /var/www/cgi-bin/sys/sys_menu.cgi
    • /var/www/cgi-bin/sys/sys_notify.cgi
    • /var/www/cgi-bin/sys/sys_streams.cgi
    • /var/www/cgi-bin/sys/sys_stream.sh
    • /var/www/html/config/index.html
    All of these files should have the permissions 0755 (-rwxr-xr-x).
    for backward compatability the following have been left in place until setup scripts have been modified.
    • /var/www/cgi-bin/sys/config.cgi
    • /var/www/cgi-bin/sys/notify.cgi
    Cron Setup
    • /etc/cron.d/stream
    #min hour day month dow user cmd
    */10 * * * * adscreen /var/www/cgi-bin/sys/sys_stream.sh "

    i have set this up as instructed but no luck.

    cron log =
    Code:
    May 11 01:10:01 mmr171 CROND[31123]: (adscreen) CMD (/var/www/cgi-bin/sys/sys_stream.sh)
    May 11 01:10:01 mmr171 CROND[31122]: (root) CMD (   ^I/root/bin/restart_show.sh)
    May 11 01:11:01 mmr171 CROND[31214]: (root) CMD (   ^I/root/bin/restart_show.sh)
    May 11 01:12:01 mmr171 CROND[31263]: (root) CMD (   ^I/root/bin/restart_show.sh)
    May 11 01:12:01 mmr171 CROND[31264]: (adscreen) CMD (/var/www/cgi-bin/sys/sys_stream.sh)
    i have set it up every 2 mins to try and force it.

    and i have also set the cron to root for the actions as well as the script.

    if i do the script manually in the terminal, it asks for a password twice...

    what am i missing?
    Last edited by adscreen; May 10th, 2013 at 04:19 PM.

  4. #4
    Join Date
    Jul 2010
    Location
    Michigan, USA
    Beans
    2,136
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Cron & rsync help needed!

    It sounds like you need to setup key based SSH login, so you can rsync without the need for entering a password each time.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •