Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am writing a sh file to take screen short and want to schedule in crontab but when i run the .sh file it run OK no problem happens but when try to schedule it in crontab i got an error like

import: unable to open X server `' @ error/import.c/ImportImageCommand/366.

my .sh file is like

#!/bin/bash
filename='ABC'
import -window root $HOME/Desktop/$filename.png

any idea how to solve it i tried with

which import

it is showing

/usr/bin/
share|improve this question

2 Answers 2

up vote 5 down vote accepted

You could probably add this line before the import line

export DISPLAY=':0'
share|improve this answer
    
Thank you very much it really work. Thank once again –  smn_onrocks Feb 18 at 11:10
    
You can what existing 'displays' you are running on using w. –  Wilf Feb 18 at 11:32

There is also a small software that can be useful for this task, allowing you some extra options, like delay between the screenshot and your command. It is called scrot.

I understand this is not your point here, but still can be a useful information for someone that google to here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.