chrome --headless

Reshad Patuck reshadpatuck1 at gmail.com
Sun May 7 07:23:57 UTC 2017


Hey,

I want to use chrome with the --headless flag on a server without an X server running to get screenshots and/or print-to-pdf of a page.

I have tried running it with xvfb on a freebsd current system.

```
root at FreeBSD:~ # service dbus onestart
root at FreeBSD:~ # Xvfb :0 -screen 0 1024x768x24 &
root at FreeBSD:~ # setenv DISPLAY :0
root at FreeBSD:~ # chrome --version
Chromium 58.0.3029.81 
root at FreeBSD:~ # chrome --headless --disable-gpu --no-sandbox --screenshot --verbose http://example.com

```

This seems to just hang (runs on the command line without any output).

---

On a debian system with chromium (57.0.2987) installed from the package repository, the command seems to run without an X sever (even xvfb) running beforehand.

```
root at debian:~# apt-get install chromium
root at debian:~# chromium --version
Chromium 57.0.2987.98 Built on 8.7, running on Debian 8.7
root at debian:~# chromium  --headless --disable-gpu --screenshot --verbose http://example.com
[0507/071136.814541:WARNING:audio_manager.cc(321)] Multiple instances of AudioManager detected
[0507/071136.814714:WARNING:audio_manager.cc(278)] Multiple instances of AudioManager detected
[0507/071137.002908:INFO:headless_shell.cc(378)] Screenshot written to file screenshot.png.
```

The command exits without error and the screenshot.png file is in the folder where the command ran from.

Some reference links:
- https://developers.google.com/web/updates/2017/04/headless-chrome
- https://chromium.googlesource.com/chromium/src/+/master/headless/README.md
- https://chromium.googlesource.com/chromium/src/+/58.0.3029.81/headless/

Best,

Reshad



More information about the freebsd-chromium mailing list