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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:22:49+00:00 2026-06-16T07:22:49+00:00

Script works well when run manually, but when I schdule it in cronjob it

  • 0

Script works well when run manually, but when I schdule it in cronjob it shows :

malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "<html>\r\n<head><tit...") at /usr/local/lib/perl5/site_perl/5.14.2/JSON.pm line 171.

script itself:

#rest config vaiables


$ENV{'PERL_LWP_SSL_VERIFY_NONE'} = 0;
print "test\n";
my $client = REST::Client->new();
$client->addHeader('Authorization', 'Basic YWRtaW46cmFyaXRhbg==');
$client->addHeader('content_type', 'application/json');
$client->addHeader('accept', 'application/json');
$client->setHost('http://10.10.10.10');
$client->setTimeout(1000);

$useragent = $client->getUseragent();

print "test\n";

#Getting racks by pod
                 $req = '/api/v2/racks?name_like=2t';
               #print " rekvest {$req}\n";
               $client->request('GET', qq($req));
               $racks = from_json($client->responseContent());
               $datadump = Dumper (from_json($client->responseContent()));

crontab -l

*/2 * * * *  /usr/local/bin/perl /folder/api/2t.pl > /dmitry/api/damnitout 2>&1

Appreciate any suggestion
Thank you,
Dmitry

  • 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-16T07:22:50+00:00Added an answer on June 16, 2026 at 7:22 am

    It is difficult to say what is really happening, but in my experience 99% issues of running stuff in crontab stems from differences in environment variables.

    Typical way to debug this: in the beginning of your script add block like this:

    foreach my $key (keys %ENV) {
        print "$key = $ENV{$key}\n";
    }
    

    Run it in console, look at the output, save it in log file.

    Now, repeat the same in crontab and save it into log file (you have already done that – this is good).

    See if there is any difference in environment variables when trying to run it both ways and try to fix it. In Perl, probably easiest is to alter environment by changing %ENV. After all differences are sorted out, there is no reason for this to not work right.

    Good luck!

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

Sidebar

Related Questions

I just finished this script it works well, but I am struggling to pass
My script works seemed to be working perfectly well, but Eclipse 3.7.2 was telling
This script works fine on single click but on double click it shows both
I have bash script which works well but when I send it back with
This script works, but only if I run it twice. Anyone have an idea
I have the following script that works well in Firefox and Chrome (not sure
I have a PHP search script which I've altered slightly and works well for
hi this is the script i have, it works well to search my database.
Hello, I’ve written a script for autocomplete like Facebook; it works well on a
I have a script I found on here that works well when looking for

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.