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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:35:15+00:00 2026-05-18T22:35:15+00:00

The direcrory structure that i am creating is thus: my $startTime = `date +%s`;

  • 0

The direcrory structure that i am creating is thus:

my $startTime = `date +%s`;
my $startTime2 = $startTime + 10;
chomp($startTime2);
print "startTime2: " . "$startTime2";
my $pwd = getcwd();

#my $PWD=system("pwd");
print "Current Working Directory: " . "$pwd\n";
my $logdir = "$pwd" . "/load-logs";
print "Log Directory: " . "$logdir\n";
#chmod( 755, $logdir ) or die "Couldn't chmod $logdir: $!";

mkdir("$logdir/$startTime2", 777) || print $!;
#print "start Time in epoc : "."$startTime";
#mkdir("$startTime3", 777) || print $!;
#system("mkdir \$logdir/$startTime");

my $reqlogfile  = "$logdir/$startTime2/req.log";
print "reqlogfile: " . "$reqlogfile\n";
my $resplogfile = "$logdir/$startTime2/resp.log";
print "resplogfile: " . "$resplogfile\n";

now, mkdir(“$logdir/$startTime2”, 777) || print $!;
does not create a directory which has the current value of $startTime2 under $logdir

  • 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-18T22:35:15+00:00Added an answer on May 18, 2026 at 10:35 pm

    A problem may be that your $logdir wasn’t created, so it’s best to ensure it is created.

    Also, it’s best to make sure the umask is reset so that if you chmod to 0777, the parent shell’s umask doesn’t interfere with the umask in the script.

    Perl’s mkdir doesn’t work as the shell’s mkdir -p (which creates intermediate directories if they do not exist). One could use mkpath from File::Path, or simply ensure the intermediate path is created, as I show below:

    use strict;
    use warnings;
    use Cwd;
    
    my $start_time   = time;   # equivalent to `date +%s`, less a shell out ;)
    my $start_time_2 = $start_time + 10;
    
    umask 000; # ensure the permissions you set are the ones you get
    
    my $pwd = getcwd();
    print "Current Working Directory: $pwd\n";
    
    my $logdir = "$pwd/load-logs";
    print "Log Directory: $logdir\n";
    
    mkdir $logdir
        or die "Cannot mkdir $logdir: $!"
        unless -d $logdir ;
    chmod 0755, $logdir or die "Cannot chmod 0755 $logdir: $!";
    
    mkdir("$logdir/$start_time_2", 0777)
        or die "Cannot mkdir $logdir/$start_time_2: $!"
        unless -d "$logdir/$start_time_2";
    
    my $reqlogfile  = "$logdir/$start_time_2/req.log";
    print "reqlogfile: $reqlogfile\n";
    my $resplogfile = "$logdir/$start_time_2/resp.log";
    print "resplogfile: $resplogfile\n";
    

    The above (with strict, warnings, etc) works for me:

    ~/t$ perl t.pl
    Current Working Directory: /home/mf/t
    Log Directory: /home/mf/t/load-logs
    reqlogfile: /home/mf/t/load-logs/1293636556/req.log
    resplogfile: /home/mf/t/load-logs/1293636556/resp.log
    

    Launching it multiple times doesn’t die, and creates the directories (and chmods them) if needed. You can check that via ls -la load-logs/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I'm working on a system that caches dynamically created files, nothing
I've written a rails app that follows the regular directory structure (model code in
Assuming the following directory structure, htdocs/ images/ css/ .htaccess system/ index.php ... I would
as weSuppose that I am creating a Java project with the following classes com.bharani.ClassOne
I have a directory structure (multiple levels deep) of resources, that I would like
When creating gems, I often have a directory structure like this: |--lib |-- helpers.rb
I am creating a quick backup script that will dump some databases into a
I’m creating an executable JAR that will read in a set of properties at
We're building a Windows-based application that traverses a directory structure recursively, looking for files
I'd like to set up a git hook that creates a CDN-style directory structure

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.