-2

I am running a Centos 7 server and I installed LAMP on it and everything works fine. I can SSH it and do all my stuff.

But it happens that I need to once every hour open a website in Chrome. I cant do that other way, I really need to have Chrome opening that website and save the screen in an image file. I was thinking about installing chrome in my Centos 7 server BUT I realized it does not have a phisical screen.

I read a lot and there is something called "screen" but I think it's not what I need. Does anyone know how to open a chrome browser window using SSH and ask my Centos to make a screenshot of it?

4
  • Possible XY problem... Why Chrome?
    – GregL
    Jun 30, 2015 at 3:30
  • I need to open Chrome for security reasons. Do you know how to open a Chrome "window" in a Centos server that does not have a monitor? My Centos is running in AWS. Jun 30, 2015 at 13:13
  • What "security reasons"? Why does it have to be Chrome? What's the actual problem you're trying to solve?
    – GregL
    Jun 30, 2015 at 13:35
  • If I say "security reasons" I dont wish to discuss it with you and turn my security reasons not so secure discussing it here. I really need to open a page and load all of its plugins once an hour so I can check that the website is working fine. No, I cant use pingdom, I need to do this using Chrome, opening it once every hour and having the screenshot saved so later I can prove the website was working fine. Jun 30, 2015 at 15:18

1 Answer 1

0

Assuming you have Chrome installed, and it somehow refreshes hourly, then you can use the import command, included with ImageMagick, to take a screenshot. If everything works as expected, setup a cronjob to run the import command once an hour.

For CentOS:
yum install ImageMagick ImageMagick-devel # I did not test this.

For Ubuntu:
apt-get install imagemagick # How I tested it.    

import -window root screenshot.png

The screen command allows you to run commands interactively, without the commands being impacted when you disconnected from a ssh session; the commands continue to run, even when you are logged out. You can later log back in and reattach to the screen session.

You can setup a display using VNC, and run the browser on the display, then capture screenshots of the display.

vncserver :1 -geometry 1920x1080 -depth 24

screen
DISPLAY=":1"; export DISPLAY; midori # Browser I tested.

Press CTRL-a d to exit the screen session running the browser.

DISPLAY=":1"; export DISPLAY; import -window root screenshot.png

To see your active screen sessions.

screen -ls

To reconnect to a screen session.

screen -r "screen id"
3
  • THANK you so much! But could you please tell me how to open chrome in the window "root" so I can use your command line above to screenshot it? Jun 30, 2015 at 13:12
  • I updated the answer. See if that gets you further.
    – Tim
    Jun 30, 2015 at 15:19
  • NICE!!!! I will try it. Thank you so much, I am very glad! Jun 30, 2015 at 15:34

Not the answer you're looking for? Browse other questions tagged .