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