LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-10-2014, 10:40 AM   #1
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Rep: Reputation: 15
Cron won't run osd_cat script


Trying to get cron to run a script that writes a desktop notification using osd_cat (part of xosd package). Runs fine from terminal. From cron it seems to try to run but instantly stops, showing "No protocol specified. Error initializing osd: Cannot open display"

I must have read every posting on Google that has anything to do with this subject. Many never indicated as solved. Others too complex for me to understand. I'm just trying to run a simple script. Have experimented with posts pointing to permissions, DISPLAY and xhost without success.

I am using openbox on both Arch and Debain wheezy. Would appreciate help, especially because osd_cat is a nicely configurable notification program.

Assuming that this can work, the objective is to run backups automatically with anacron, but preceeded with a notification to insert a USB drive.
 
Old 04-10-2014, 12:07 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
#!/bin/bash
# make_popup <icon> <title> [<text>]
icon=/home/jj/Documents/dork.png
title="OSD Popup Test"
text="LQ Rocks!"
logfile=~/notify.sends
notify-send -i $icon "$title" "$text"
echo $title $text `date +"%a, %b %d %Y at %l:%M:%S %p %Z"`>$logfile
exit 0
You may need a DISPLAY variable and I'm not certain this will work from anacron, but hey, it's a start.

Enjoy the LQ goodness!

Last edited by Habitual; 06-26-2015 at 05:47 PM.
 
Old 04-15-2014, 04:07 PM   #3
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Original Poster
Rep: Reputation: 15
Thanks, habitual. No doubt your script would show the notification if I were to install notify-osd (a ubuntu-developed program that includes notify-send). But my problem is that when anacron tries to run my osd_cat (part of xosd-bin on Debian) script, it immediately shuts down without putting it on the screen. It would probably do the same with yours.

On the other hand if as root I give the command: anacron -fn, the notification appears immediately on the screen (the -f option means ignore time stamps and the -n option means run now).

So I conclude that anacron and my script are doing the job, but that there is some other impediment that I can't figure out.
 
Old 04-15-2014, 05:35 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
maybe in sudoers give yourself permission to run anacron?
 
Old 04-17-2014, 10:04 AM   #5
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Original Poster
Rep: Reputation: 15
Curiosly, just typing * * * * * in a terminal runs the script, displaying the desktop notification.
 
Old 04-17-2014, 10:42 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
maybe you should show us the actual commands and script you are using?
 
Old 04-18-2014, 10:15 AM   #7
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Original Poster
Rep: Reputation: 15
The script:
Code:
cat /usr/local/bin/alert
#!/bin/bash

export DISPLAY=:0
echo "Insert Backup USB" | osd_cat -A center -p middle -c blue -d 10 -f -*-*-bold-*-*-*-36-120-*-*-*-*-*-* &&
sleep 7 && echo "Done" | osd_cat -A center -p middle -c red -d 10 -f -*-*-bold-*-*-*-36-120-*-*-*-*-*-*
The anacron command:
Code:
cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root
DISPLAY=:0
START_HOURS_RANGE=8-22
RANDOM_DELAY=20

# These replace cron's entries
1	1	alertscript	nice	alert
1 	7	cron.daily	nice    run-parts --report /etc/cron.daily
7	10	cron.weekly	nice	run-parts --report /etc/cron.weekly
@monthly	15	cron.monthly	nice	run-parts --report /etc/cron.monthly
The error report sent to /var/mail/my-home-name:
Code:
From root@debian Fri Apr 18 07:46:45 2014
Return-path: <root@debian>
Envelope-to: root@debian
Delivery-date: Fri, 18 Apr 2014 07:46:45 -0400
Received: from root by debian with local (Exim 4.80)
	(envelope-from <root@debian>)
	id 1Wb7Fl-0000uf-C5
	for root@debian; Fri, 18 Apr 2014 07:46:45 -0400
From: Anacron <root@debian>
To: root@debian
Subject: Anacron job 'alertscript' on debian
Content-Type: text/plain; charset=US-ASCII
Message-Id: <E1Wb7Fl-0000uf-C5@debian>
Date: Fri, 18 Apr 2014 07:46:45 -0400

No protocol specified
Error initializing osd: Cannot open display
 
Old 04-18-2014, 10:25 AM   #8
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Original Poster
Rep: Reputation: 15
Perhaps I should add:

Code:
cat /etc/cron.d/anacron
# /etc/cron.d/anacron: crontab entries for the anacron package

DISPLAY=:0.0
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

30 7 * * *   root	test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
 
Old 04-19-2014, 09:51 AM   #9
hilltownboy
Member
 
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123

Original Poster
Rep: Reputation: 15
It turns out that changing /etc/cron.d/anacron from 30 7 * * * to * * * * * resolves the problem
My desktop notification script now runs as intended
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian daily cron job won't run, but does run in cron.hourly. sandersch Linux - General 7 05-24-2012 01:50 AM
.sh script won't tar when run from cron jonathansfl Linux - Newbie 1 05-08-2011 11:47 AM
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
Cron won't open console to run script rollo Linux - General 5 11-10-2006 01:56 PM
Script creats temporary files... Cron won't run it spiffytech Linux - Software 5 01-11-2006 10:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration