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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-10-2014, 11:40 AM
|
#1
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Rep:
|
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.
|
|
|
04-10-2014, 01:07 PM
|
#2
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep:
|
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 06:47 PM.
|
|
|
04-15-2014, 05:07 PM
|
#3
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Original Poster
Rep:
|
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.
|
|
|
04-15-2014, 06:35 PM
|
#4
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep:
|
maybe in sudoers give yourself permission to run anacron?
|
|
|
04-17-2014, 11:04 AM
|
#5
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Original Poster
Rep:
|
Curiosly, just typing * * * * * in a terminal runs the script, displaying the desktop notification.
|
|
|
04-17-2014, 11:42 AM
|
#6
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep:
|
maybe you should show us the actual commands and script you are using?
|
|
|
04-18-2014, 11:15 AM
|
#7
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Original Poster
Rep:
|
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
|
|
|
04-18-2014, 11:25 AM
|
#8
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Original Poster
Rep:
|
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
|
|
|
04-19-2014, 10:51 AM
|
#9
|
Member
Registered: Jan 2008
Location: Ashfield, MA
Distribution: Debian 11 "Bullseye", Arch
Posts: 123
Original Poster
Rep:
|
It turns out that changing /etc/cron.d/anacron from 30 7 * * * to * * * * * resolves the problem
My desktop notification script now runs as intended
|
|
|
All times are GMT -5. The time now is 06:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|