• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:


i have a cronjob that runs  rahul.pl

rahul.pl contains

$string .= "\nTesting\n";
#$string =~ s/\n/\\\n/g;
#$string =~ s/'/'"'"'/g;
system "ssh", "out1", "/u/rshah1/temp.pl", "'$string'";

it does not works it does not login to out1 machine

however if i run rahul.pl manually from command prompt it works fine. i have set up sshkeygen

2 Solutions
shahrahulbAuthor Commented:
ssh is not working thru cronjob
There are a variety of differences between the environment a process sees when it is run from the command line and the environment it sees if it is executed as a cron job.

The first question I'd have to ask is whether the cron job is running on your behalf. The ssh keys are user-specific.
I;d probably also code the entire path to the ssh command in your system(). As jmcg has explained, PATH is one environment variable which is not available when a script is run thru cron

system "/absolute/path/to/ssh", "out1", "/u/rshah1/temp.pl", "'$string'";
Make sure that your pl has the approriate attributes. chmod it to 755 or else the cronjob wont't have authority to execute it.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now