5

I'm trying to execute a cron job with Scrot (screenshot utility) but it won't work.

At first I thought it was a directory problem. I wrote my.png by itself at first, which could have been dropping it anywhere. So I changed the command to use the absolute paths. Since I've defined absolute paths, it seems like it would have to work correctly, but it's not. If I try to execute this as written on the command line, it works.

32 8,14,16 * * 1-5 /usr/bin/scrot /home/johndoe/my.png

What am I doing wrong?

Note that the times are not the problem, I keep putting it one or two minutes ahead of the current system time to test, and for other commands, it works fine.

1 Answer 1

8

Change the line in your crontab to this:

32 8,14,16 * * 1-5 DISPLAY=:0 /usr/bin/scrot /home/johndoe/my.png
2
  • Great! Glad it worked. Please consider marking the answer as accepted to help clean up and clarify the site's contents.
    – SirCharlo
    Sep 28, 2012 at 14:09
  • I added this line in crontab not working, can someone find what is the problem * * * * * 1-5 DISPLAY=:0 /usr/bin/scrot /home/mani/$(date -d "today" +"%Y%m%d%H%M").png . But works in command line.
    – Mani
    Oct 29, 2022 at 13:33

You must log in to answer this question.

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