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

  • SEARCH
  • Home
  • 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 6081919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:13:50+00:00 2026-05-23T11:13:50+00:00

I have a perl script runs in cron and if the script fails to

  • 0

I have a perl script runs in cron and if the script fails to run it leaves behind a lock file to prevent the script to run again.

I’m trying to run a bash script that checks if the process is running and checks to see if a lock file is left behind

if processes is running and lock file exists
exit 0;

if process is not running and lock file exists
rm lockfile.
exit 0;

if process does not exist and lock file is ‘not present’
exit 0;

I’ve been checking if the process exists running
ps ax |grep -v grep |grep process.pl

I’m looking for the conditionals in bash that I should be running here.

Thanks

  • 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-05-23T11:13:50+00:00Added an answer on May 23, 2026 at 11:13 am

    The process.pl should write its process id into the lockfile, wihch is a common pattern. Then you can write the following code:

    if [ -f "$lockfile" ]; then
      pid=$(cat "$lockfile")
      if kill -0 "$pid"; then
        : "running normally"
      else
        : "terminated somehow"
        rm -f "$lockfile"
      fi
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Perl script which runs as a Linux daemon using an
I have a Perl script that I'd like to run on Windows, using either
I have a Perl script that uses WWW::Mechanize to read from a file and
I have written a Perl script that runs as a daily crontab job that
Currently I have a perl script that runs forever on my server, checking a
I currently have a Perl script that runs an external command on the system,
Started to learn some shell scripting. I have a perl script that runs on
I have a perl script (which syncs delicious to wp) which: runs via the
I have a simple perl script that uses DBD::Oracle to run a query and
I have a Perl program, intended to be run from a subversion post-commit script,

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.