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 8152213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:38:47+00:00 2026-06-06T15:38:47+00:00

currently i’m trying to do something like this: 1 cron job backup_daily 2 cron

  • 0

currently i’m trying to do something like this:

  • 1 cron job backup_daily
  • 2 cron job backup_weekly
  • 3 cron job backup_monthly

so, what might happen is that for example daily and weekly will run at the same day. atleast one of them will fail since the file which should be backed-up is locked by the other backup process. so, one simple solution would be to run the jobs at different times. but since we can’t say exacly how long a job will take, thats kinda ugly.

so what i was thinking about is a proxy script, so instead of doing the above cron jobs i would do something like

  • 1 cron job check_if_anybackup_is_running_and_run_backup_daily_else_wait_till_finished
  • 2 cron job check_if_anybackup_is_running_and_run_backup_weekly_else_wait_till_finished
  • 3 cron job check_if_anybackup_is_running_and_run_backup_monthly_else_wait_till_finished

then the only thing i would care about is that they start with a offset of any time so they dont block each other. also the “wait” time should be choosen wisely so they dont “recheck” at the same moment and again block each other (with 3 processes we could use a offset +1 for proccess weekly, +2 for proccess monthly and even / uneven counters for the recheck time)

however, i’m not sure how to realize this with a linux script. i’m not sure what the “right” procedure would be. use a lockfile which is created at process start and check that? and what happens if it’s locked? is it a “good” method to just use sleep and check the lock file again after time X? I’m not sure about what happens when i use sleep on a linux thread – i mean: is the “counter” scheduled and using up processor power or is there some kind of interrupt that the processor will send to the process waiting after a time X (like “event based”?)
are there any nicer methods you could think of? some linux script code snippets would be perfect since thats not really the thing i ever did before

  • 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-06T15:38:48+00:00Added an answer on June 6, 2026 at 3:38 pm

    I would combine all three scripts into one with different parameters. Like do_backup.sh daily.

    You’re correct about using same lock file. I would go further and write your process PID in this lock file. This way if your process sees that lockfile exists it doesn’t just bail out, but check is process who create this file still running. This way even if your process crashes and doesn’t delete lock file – your whole system is still safe.

    Here is sample I use in my scripts to ensure only one copy is running at the same time:

    #!/bin/sh
    
    PID_FILE=$0.pid
    [ -f $PID_FILE ] && {
       pid=`cat $PID_FILE`
       ps -p $pid && {
          echo Already running...
          exit
       }
       rm -rf $PID_FILE
    }
    
    echo $$ > $PID_FILE
    

    And then in your script you would just include this file

    source pid.sh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, my ListViews look like this: How can I achieve that Windows 7 native
Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
Currently working with converting SQLException error messages into messages that are more useful for
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
Currently I am trying to use a bunch of custom perl modules, test.pm as
Currently I am debugging the signing of an Android app. And this would be
Currently I am adding object by creating it like: type TRecord = class private
Currently, most of the popular websites, like google, yahoo detect if the user connection
Currently, my MVC 3 app has a dependency on a static class that is
Currently, Enum.Parse supports only the comma as the value separator, so that MemberOne,MemberThree will

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.