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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:48:16+00:00 2026-05-19T15:48:16+00:00

I’m writing a script in Perl that needs to run at the same time

  • 0

I’m writing a script in Perl that needs to run at the same time every night, except sometimes that time needs to change. I found Schedule::Cron on CPAN, and it does what I want it to do. According to the documentation for the run method,

nofork => 1

Don’t fork when starting the scheduler. Instead, the jobs are executed within current process. In your executed jobs, you have full access to the global variables of your script and hence might influence other jobs running at a different time.

Which is what I want to do, but it is not doing. Whenever I examine the global variables memory location, they are the same, but the value is not changed when the the task starts.

I’ve run this on both Windows and Linux, and I’ve had someone else look at the code to see if my logic was correct. What do I need to do to keep the changes to the global variables.

use warnings;
use strict;

use Schedule::Cron;
use Time::localtime;

use constant {
    EVERY_DAY_10PM => '* * * * * 4,16,28,40,52',
    EVERY_DAY_NOON => '* * * * * 0,12,24,36,48',
    EVERY_DAY_2AM => '* * * * * 7,19,31,43,55'
};

############GLOBAL VARIABLES############
our $cron = new Schedule::Cron(\&runUpdate);
our $cronId;
our $updateTimeDirty = 0;
############END GLOBAL VARIABLES############

############MAIN PROGRAM BODY############
$cronId = $cron->add_entry(EVERY_DAY_10PM);#defaults to \&runUpdate
$cron->add_entry(EVERY_DAY_NOON, \&changeTime);
$cron->run(no_fork => 1);
############END MAIN PROGRAM BODY############

sub changeTime {
    our $cron;
    our $cronId;
    our $updateTimeDirty;

    print "updateTimeDirty is $updateTimeDirty\n";
    print "udpateTimeDirty location: " . \$updateTimeDirty . "\n";
    print "cron object: " . \$cron . "\n";

    if ($updateTimeDirty) {
        my $cronEntry = $cron->get_entry($cronId);
        $cronEntry->{time} = EVERY_DAY_2AM;
        $cron->update_entry($cronId, $cronEntry);
    }
    print "\n";
}

sub runUpdate {
    our $updateTimeDirty;

    $updateTimeDirty = 1;
    print "Updating at " . localtime()->sec . " ($updateTimeDirty)\n\n";
}
  • 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-19T15:48:17+00:00Added an answer on May 19, 2026 at 3:48 pm

    There’s a significant difference between no_fork and nofork. Try:

    $cron->run(nofork => 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.