2

The below script run all fine it self, but not able to run with task scheduler. Please suggest.

I have tried executing the script in terminal and it runs fine.

#!/bin/bash
#Take screenshot
import -window root $HOME/screenshot.png
#Move to dropbox folder
mv $HOME/screenshot.png $HOME/$(date|tr " :" _).png

1 Answer 1

0

Because import command capture some or all of an X server screen, this means that it takes actions on your screen/display, so, when you use it in a task scheduler or in a cron job or something similar, you must to set first the value of DISPLAY environment variable to :0.0. See Graphical desktop-related variables for more info.

So, your script should look like:

#!/bin/bash
#Take screenshot
export DISPLAY=:0
import -window root $HOME/screenshot.png
#Move to dropbox folder
mv $HOME/screenshot.png $HOME/$(date|tr " :" _).png

Don't forget to make the script executable, using the following command:

chmod +x /path/to/script_name

You must log in to answer this question.

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