Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run screen from Perl

I have a Jar file that I would like to run through screen, although when I try to open the Perl script everything seems to be working fine, although when I do top I do not see the process in the list, it works just fine if I copy-paste the command into the SSH session...

This is the code I'm using:
start.pl

# !/usr/local/bin/perl
system("cd /var/server/; screen java -Xmx1024M -Xms1024M -jar jarfile.jar > /dev/null 2>&1 &");

Can someone point out why this is?

like image 383
Justin Avatar asked May 10 '11 16:05

Justin


1 Answers

The problem is that screen is trying to grab hold of the terminal, which isn't possible given the context of the system command. The easiest solution is to start the screen session in detached mode by adding the -d -m options:

# !/usr/local/bin/perl
system("cd /var/server/; screen -d -m java -Xmx1024M -Xms1024M -jar jarfile.jar > /dev/null 2>&1 &");
like image 177
ESultanik Avatar answered Oct 11 '22 19:10

ESultanik