Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:49:57+00:00 2026-06-14T06:49:57+00:00

I have cronjob to run a script every day in specific time. The script

  • 0

I have cronjob to run a script every day in specific time. The script is for conversion a large file (about 2GB) in specific folder. The problem is that not every day my coleague put the file in the folder before the time, written as cronjob.

Please help me to add commands in the script or to write second script for:

  1. Check if the file exists in the folder.
  2. If the previous action is true, check the file size every minute. (I would like to avoid conversion of still incomming large file).
  3. If filesize stays unchanged for 2 minutes, start the script for conversion.

I give you the important lines of the script so far:

cd /path-to-folder
for $i in *.mpg; do avconv -i "$i" "out-$i.mp4" ; done

10x for the help!

NEW CODE AFTER COMMENTS:

There is file in the folder!

#! /bin/bash


cdate=$(date +%Y%m%d)
dump="/path/folder1"
base=$(ls "$dump")

if [ -n "$file"]
then
    file="$dump/$base"
    size=$(stat -c '%s' "$file")
    count=0
    while sleep 10
    do
        size0=$(stat -c '%s' "$file")
        if [ $size=$size0 ]
        then $((count++))
             count=0
        fi
        if [ $count = 2 ]
        then break
        fi
    done
    # file has been stable for two minutes. Start conversion.

CONVERSION CODE

fi

MESSAGE IN TERMINAL: Maybe error???

script.sh: 17: script.sh: arithmetic expression: expecting primary: "count++"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:49:59+00:00Added an answer on June 14, 2026 at 6:49 am

    Well, I finally made some working code as follows:

    #!/bin/bash
    
    cdate=$(date +%Y%m%d)
    folder1="/path-to-folder1"
    
    cd $folder1
    
    while file=$(ls "$folder1")
          [ -z "$file" ]
    do sleep 5 && echo "There in no file in the folder at $cdate."
    done
    
    echo "There is a file in folder at $cdate"
    size1=$(stat -c '%s' "$file")
    echo "The size1 is $size1 at $cdate"
    size2=$(stat -c '%s' "$file")
    echo "The size2 is $size2 at $cdate"
    if [ $size1 = $size2 ]
    then
    echo "file is stable at $cdate. Do conversion."
    

    Is the next line the right one to loop the same script???

    else sh /home/user/bin/exist-stable.sh
    fi
    

    The right code after comments below is

    else exec /home/user/bin/exist-stable.sh
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a php script that should be run automatically every day. as the
I have a perl script which Im planning to run every minute. I have
I have a php script that needs to run once every 5 minutes. Currently
I have a cron job to run a Ruby script, which runs fine on
If I have a cron job that run every 10 minutes and for some
I have a PHP page that I run every minute through a CRON job.
I have a cronjob calling a shell script. Inside that shell script and I
Some setup background first: I have a cronjob which runs a PHP file called
I have a cron job running a PHP script every five minutes; the PHP
I have a shell script file for monitoring my application, this script will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.