Running cron on Cygwin to call notifu

3

I have installed Cygwin with cygrunsrv and Cron so I could use the benefits of using Linux-style scheduling in Windows. I want to call notifu from a cron job.

I Installed cron as a service using the command:

cygrunsrv -I cron -d "CYGWIN cron" -u cron_srv -p /usr/sbin/cron -a -n

Everything is ok, the service is running and not reporting any errors. Also I gave this cron_srv user all privileges it needs, so it can switch user contexts etc.

crontab -l gives these two jobs I have defined:

HOME=/home/<username>
PATH=/usr/local/bin:/usr/bin:/bin:/cygdrive/c/utils/notifu:$PATH
# testing
* * * * * echo "Cron test at $(date +\%k:\%M)" >> ~/testcron.txt 2>&1
* * * * * notifu /p "Balloon Title" /t warn /w /m "event description"

cronevents gives this:

2014/03/03 13:08:01 [cron_srv] /usr/sbin/cron: PID 2592: (branchito) CMD (echo "Cron test at $(date +%k:%M)" >> ~/testcron.txt 2>&1)
2014/03/03 13:08:01 [cron_srv] /usr/sbin/cron: PID 4076: (branchito) CMD (notifu /p "Balloon Title" /t warn /w /m "event description")

..so no errors. And I have my testcron.txt file created, and populated correctly with my custom date test. But notifu does not pop up a balloon with message, although it does not report any error in cronevents, and appears to be executed just as well as his friend date test job.

I set my PATH variable explicitly so it can find the notifu program, even though it is contained in the last appended PATH, but I wanted to be sure.

The interesting part is that the notifu command runs without any problem from Cygwin terminal, balloon is popping with message all well, but from thecron job it is not trigerring.

I read something about the DISPLAY environment variable, could that be a problem maybe? If so, how would I set its value in the crontab file? On Linux it is like DISPLAY=:0.0, but I don't know how to set this value on Windows.

EDIT

Doing some more research, I came to know that the problem lies in the fact that as of Windows Vista, services act only and only in session 0 isolation level, so they cannot interact with Desktop as a security precaution, or they can but in some special way of secure desktop instance.

I would like someone to tell me how it would be possible in this case (my case), for this service to be able to send message to that notifu app, justo to popup balloon tip with that message, and would that be possible without modifing service itself, because I am not the author of it. So is there any way I could give that service some logon as permissions, so it would act in userspace.

branquito

Posted 2014-03-03T13:22:42.930

Reputation: 203

Notifu doesn't use X11, so DISPLAY doesn't apply. It's a native Windows application, not part of Cygwin. The problem may be related to the way cron is a service running in a different context from the user session. As this question is highly likely to require Windows expertise, it would be better off on [su]. The relevance to [unix.se] is at best marginal. I've flagged for migration to [su], please do not repost. – Gilles 'SO- stop being evil' – 2014-03-03T21:19:56.747

What Windows version, please? I think I have a method that could help you, but it differs between XP and 7. – Sopalajo de Arrierez – 2014-03-08T03:12:41.220

it is windows 7, thank you. because windows xp does not have that problem, session 0 isolation was first introduced in windows vista. – branquito – 2014-03-09T17:51:26.737

Excuse me for the delay, @branquito. I hope to face this problem as soon as possible, but I think I will last some days, so here is the link to the possible (probable?) solution to your question: http://stackoverflow.com/a/4284420/1461017 . It is not an easy to do thing, but I think it will work. When I will have some more concrete results about it, I will post them here, of course.

– Sopalajo de Arrierez – 2014-04-27T22:12:46.460

@SopalajodeArrierez thanks, I will take a look. – branquito – 2014-04-27T22:53:40.600

No answers