-1

I know that this was asked several times, but I don't know what to do... I've tried all the solutions proposed on AskUbuntu, but with no results...

So... I have this shell script in my home /home/napolux:

#!/bin/bash
NOW=$(date +"%Y%m%d-%T")
cutycapt --url=http://example.com --out=/home/napolux/screens/yc.$NOW.png

The crontab is this:

* * * * * /home/napolux/yc-screens > /dev/null

cutycapt is a small command line tool that takes screenshots of webpages. The script (and the destination folder /home/napolux/script) as 777 permissions with execution flag.

The script is correct: by calling it via shell I can get the screenshot.

In /var/log/syslog I see the job running every minute.

May 18 20:13:01 ubu CRON[2649]: (CRON) info (No MTA installed, discarding output)
May 18 20:14:01 ubu CRON[2657]: (napolux) CMD (/home/napolux/yc-screens > /dev/null)
May 18 20:14:01 ubu CRON[2656]: (CRON) info (No MTA installed, discarding output)
May 18 20:15:01 ubu CRON[2662]: (napolux) CMD (/home/napolux/yc-screens > /dev/null)
May 18 20:15:01 ubu CRON[2661]: (CRON) info (No MTA installed, discarding output)

So, what can I do???

4
  • 5
    one note: never set a script to be chmod 777 - that means any user can edit the script as well as run it, which is a giant security hole. 755 is much safer. May 18, 2012 at 21:18
  • It's a develpoment virtual machine with no security issue. I know which kind of permissions I have to set in real prod env. ;)
    – napolux
    May 18, 2012 at 21:24
  • 5
    @Napolux: It's never too early to develop good habits. May 18, 2012 at 22:07
  • I have good abits, but sometimes you simply don't need them :)
    – napolux
    May 19, 2012 at 11:14

2 Answers 2

2

To get debugging output and being able to figure what's happening, I suggest you don't redirect output to /dev/null. You can either redirect to a file or remove the redirection altogether, in which case it will email your local user with a report. You can also set a MAILTO variable to have it send e-mail out to someone else (assuming you have a MTA correctly set up on the system).

So either:

* * * * * /home/napolux/yc-screens > /tmp/yc.log

or:

[email protected]
* * * * * /home/napolux/yc-screens

My hunch is that you need to provide a full path to cutycapt (/usr/bin/cutycapt) but it may be something else. The best way to know for sure is to look at logs.

Also, I suggest you don't set the script and directory as 777, as that allows anyone to mess with them. Instead, set them as 755 and ensure that your user has permissions to write to the directory.

1
  • Tried your solution (log + abs. path to cutycapt). No output on log, no images saved... :(
    – napolux
    May 18, 2012 at 20:58
1

Found the problem... cutycapt needs some sort of X server to work properly, so I used xvfb as explained here...

http://jamesmcdonald.id.au/it-tips/taking-screenshots-of-a-website-in-linux

2
  • 1
    Oh you kids these days with your fancy X servers and your GUIs :p Also consider wkhtmltoimage (link), which does not need any sort of X server and is available as a static binary (no dependencies).
    – ish
    May 18, 2012 at 22:08
  • Kid? I'm 30 years old and my first computer was an 80286 :P
    – napolux
    May 19, 2012 at 11:13

You must log in to answer this question.

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