LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-01-2014, 08:44 AM   #1
lwv962
Member
 
Registered: Feb 2011
Location: Wales
Distribution: Debian 8.6.0
Posts: 34

Rep: Reputation: 0
The "at" command , cannot get it to work correctly


Hi everybody,

All I can do with the "at" command is to write or append some text to a

file; it refuses to run commands such as cd , ls , or any other command

including running functions . I've searched for days and found nothing

has anyone any suggestions ?

I will be very grateful to know

lwv962
 
Old 09-01-2014, 11:05 AM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,280

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Works OK for me, see below illustrating successful use of cd and ls. Can you post exactly the commands you are entering?

Code:
$ at now + 1 minute
warning: commands will be executed using /bin/sh
at> cd /tmp
at> ls /boot > ./at.out
at> <EOT>
job 6 at Mon Sep  1 09:03:00 2014
$ sleep 60; cat /tmp/at.out
abi-3.2.0-23-generic
config-3.2.0-23-generic
grub
initrd.img-3.2.0-23-generic
memtest86+.bin
memtest86+_multiboot.bin
System.map-3.2.0-23-generic
vmlinuz-3.2.0-23-generic
$
 
1 members found this post helpful.
Old 09-01-2014, 11:34 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
at does not put its output to STDOUT

man at
Code:
The  user will be mailed standard error and standard
output from his commands, if any.
 
Old 09-01-2014, 01:55 PM   #4
lwv962
Member
 
Registered: Feb 2011
Location: Wales
Distribution: Debian 8.6.0
Posts: 34

Original Poster
Rep: Reputation: 0
haertig,keefaz,
Thanks for responding,yes I agree haertig,your eg. wrote to file the difference was that when I wrote to file I
used a full path and you used cd . But when I use sleep 60s ; cd /rhag , or sleep 17s ; cadno ,the cd changes on
my terminal in the first case and in the 2nd case activates a function which switches on a radio station ; that's
what I'm looking for in "at".BTW I have not got mail installed . I have tried over 250 examples and the best I had
was writing to file , which I think you'll agree is a thankless task !
The Main Question is HOW , using "at" Would You activate a function , run a programme or run a command directly ?

Last edited by lwv962; 09-01-2014 at 01:57 PM. Reason: to add 2 words
 
Old 09-01-2014, 02:27 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,280

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by lwv962 View Post
But when I use sleep 60s ; cd /rhag , or sleep 17s ; cadno ,the cd changes on
my terminal in the first case and in the 2nd case activates a function which switches on a radio station ; that's
what I'm looking for in "at".
Unfortunately, I cannot understand exactly what you are trying to say here. Can you post the exact commands you are giving to "at"? Like I did in my post. Just do exactly what you are attempting in your terminal window, then highlight and cut-n-paste everything into your next post (preferably surrounded with [ code ] tags for readability). If you are trying to run a script rather than just standard commands, post that script as well (unless it's 10 bazillion lines long).

I'm especially confused by this statement:
Quote:
in the 2nd case activates a function which switches on a radio station
Are you trying do make a permanent change in your system using at? If you are using at to start a process, that process will be killed when the at shell exits, unless you use nohup, backgrounding of the process, etc. Just like you would have to do manually from your shell command line to make a process persist past your logoff.
 
1 members found this post helpful.
Old 09-01-2014, 05:50 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Quote:
Originally Posted by lwv962 View Post
haertig,keefaz,
Thanks for responding,yes I agree haertig,your eg. wrote to file the difference was that when I wrote to file I
used a full path and you used cd . But when I use sleep 60s ; cd /rhag , or sleep 17s ; cadno ,the cd changes on
my terminal in the first case and in the 2nd case activates a function which switches on a radio station ; that's
what I'm looking for in "at".BTW I have not got mail installed . I have tried over 250 examples and the best I had
was writing to file , which I think you'll agree is a thankless task !
The Main Question is HOW , using "at" Would You activate a function , run a programme or run a command directly ?
Nothing in /var/spool/mail/lwv962?
(or whatever your username is)

Maybe the radio command needs a display to work

Try running your command with:
Code:
DISPLAY=:0.0 /usr/bin/yourcommand ...
 
1 members found this post helpful.
Old 09-01-2014, 06:02 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Quote:
Originally Posted by haertig View Post

Are you trying do make a permanent change in your system using at? If you are using at to start a process, that process will be killed when the at shell exits, unless you use nohup, backgrounding of the process, etc. Just like you would have to do manually from your shell command line to make a process persist past your logoff.
No, at is not attached to any shell. Even if you log out, at continues to work, no need for nohup etc
 
Old 09-01-2014, 06:48 PM   #8
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,280

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by keefaz View Post
No, at is not attached to any shell. Even if you log out, at continues to work, no need for nohup etc
I was not intending to say that "at" required you to stay logged in (that would kind of defeat its purpose). What I meant was that if at starts some command, then that command (not at itself) is subject to the same termination rules as anything you'd start manually from the command line. Of course, if at starts a program and that program runs for ever, then your at job will never complete, it will just continue to run. What I was trying to say, and I think I failed at it, was if you have at run "mycommand &" rather than "nohup mycommand &", then mycommand may well terminate when your at job completes. I am not entirely sure if mycommand would terminate or not in that situation, it may indeed keep running, but to be on the safe side I'd use the nohup, just in case.

One thing to note: If your system reboots, then all your scheduled "at" jobs are lost. "cron" jobs will resume after a reboot, but "at" jobs are lost. At least they were all lost in past times under the Solaris OS, I haven't checked for many years, and maybe things are different now or Linux preserves them. Honestly, I haven't verified recently and just continue to assume they will be lost as I have seen in the past.
 
Old 09-01-2014, 07:45 PM   #9
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Good point, thanks for clarify

Quote:
Originally Posted by haertig View Post
What I was trying to say, and I think I failed at it, was if you have at run "mycommand &" rather than "nohup mycommand &", then mycommand may well terminate when your at job completes. I am not entirely sure if mycommand would terminate or not in that situation, it may indeed keep running, but to be on the safe side I'd use the nohup, just in case.
Not necessarly, If I try;
Code:
at now +1 minute
DISPLAY=:0.0 /usr/bin/xclock &
<EOT>
It opens an xclock window after one minute as expected, running until closed, well after at job finished.
I don't see the point of running command in background with at, though
 
1 members found this post helpful.
Old 09-02-2014, 10:33 AM   #10
lwv962
Member
 
Registered: Feb 2011
Location: Wales
Distribution: Debian 8.6.0
Posts: 34

Original Poster
Rep: Reputation: 0
haertig

here are some examples of my efforts.You will notice the `sleep"s and the last `at" worked.

As you can see from the job number I have tried a few times !



Code:
peter@peter-Lenovo-G580 ~ $ at now + 1 minute
warning: commands will be executed using /bin/sh
at> cd ~/rhag
at> <EOT>
job 276 at Mon Sep  1 21:16:00 2014
peter@peter-Lenovo-G580 ~ $ 
peter@peter-Lenovo-G580 ~ $ date
Mon Sep  1 21:16:10 BST 2014
peter@peter-Lenovo-G580 ~ $ 

peter@peter-Lenovo-G580 ~ $ sleep 50; cd ~/rhag
peter@peter-Lenovo-G580 ~/rhag $ date
Mon Sep  1 21:20:50 BST 2014
peter@peter-Lenovo-G580 ~/rhag $ 
 

peter@peter-Lenovo-G580 ~ $ at  now + 1 minutes
warning: commands will be executed using /bin/sh
at> cadno
at> <EOT>
job 277 at Mon Sep  1 21:28:00 2014
peter@peter-Lenovo-G580 ~ $ 
peter@peter-Lenovo-G580 ~ $ date
Mon Sep  1 21:28:06 BST 2014
peter@peter-Lenovo-G580 ~ $ 

peter@peter-Lenovo-G580 ~ $ sleep 45; cadno
Trying to load URL: goes here " I've withheld it for licensing reasons"
Setting current radio through DBus...
peter@peter-Lenovo-G580 ~ $ date
Mon Sep  1 21:30:43 BST 2014
peter@peter-Lenovo-G580 ~ $ 

cadno () {
		
	radiotray url goes here
	}

peter@peter-Lenovo-G580 ~ $ at now +1 minute
warning: commands will be executed using /bin/sh
at> DISPLAY=:0.0 /usr/bin/radiotray http:// "I've withheld the url for licensing reasons "
at> <EOT>
job 285 at Tue Sep  2 10:15:00 2014
Quote:
Are you trying do make a permanent change in your system using at? If you are using at to start a process, that process will be killed when the at shell exits, unless you use nohup, backgrounding of the process, etc. Just like you would have to do manually from your shell command line to make a process persist past your logoff.
No permanent change I just wanted to activate a function , btw I haven't tested it but `at", if one has passed the
time specified will put the job for the next day according to `at -l". With reference to the "2nd.case",an unfortunate choice of word especially in a `bash" context, I should have written 'example'.
PS. I hadn't read your latter post when I wrote this - I'll leave it in for continuity .


keefaz,
Absolutely nothing in /var/spool/mail/.
DISPLAY=:0.0 /usr/bin/yourcommand .. -- YES perfect.

haertig , keefaz ,
I think your last two posts have been covered .
the : `DISPLAY=:0.0 /usr/bin/yourcommand" works with firefox,radiotray etc. with the URL added, also with other GUIs.
Only one thing puzzles me how would one activate a function that was in ~/bashrc ,~/bash_aliases or in a script ?
 
Old 09-02-2014, 10:43 AM   #11
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
You have to source your script or bashrc AFAIK

eg, if cadno() is defined in .bashrc

Code:
at 16:45
export DISPLAY=:0.0
source /home/peter/.bashrc
cadno
<eot>
 
Old 09-02-2014, 11:14 AM   #12
lwv962
Member
 
Registered: Feb 2011
Location: Wales
Distribution: Debian 8.6.0
Posts: 34

Original Poster
Rep: Reputation: 0
Post

Hi keefaz,


Quote:
export DISPLAY=:0.0
source /home/peter/.bashrc
cadno
<eot>
No luck with this !

Any ideas ?
 
Old 09-02-2014, 12:01 PM   #13
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Can you post your .bashrc file or it's secret?
 
Old 09-02-2014, 01:22 PM   #14
lwv962
Member
 
Registered: Feb 2011
Location: Wales
Distribution: Debian 8.6.0
Posts: 34

Original Poster
Rep: Reputation: 0
As I'm on Mint there was no ~/.bashrc so I had to create one to put my aliases and functions
in, I don't know how much good it would be . There is one in /etc/bash.bashrc. would that be
OK ,btw there's no security in .bashrc is there ?
 
Old 09-02-2014, 01:39 PM   #15
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
In your .bashrc, in cadno function try to write the full path to radiotray just in case.

eg
Code:
cadno () {
		
	/usr/bin/radiotray url goes here
	}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
command "tree" can't display output correctly in xemacs shell philip518 Linux - Newbie 4 05-24-2012 01:48 PM
"ip route flush table main" doesn't work correctly from rc.local? gleemer Linux - Networking 0 08-17-2011 06:03 PM
pwmconfig correctly detects fans but "test" doesn't work...? shock_ez Linux - Software 0 05-07-2009 11:35 AM
Syslinux doesn't correctly interpret kernel="/foo/bar" command lumix Linux - Newbie 4 06-19-2008 01:15 PM
How to use "useradd" command correctly? hus Linux - Newbie 3 05-12-2004 02:20 PM

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

All times are GMT -5. The time now is 12:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration