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.
|
 |
|
09-01-2014, 07:44 AM
|
#1
|
Member
Registered: Feb 2011
Location: Wales
Distribution: MX Linux 18
Posts: 36
Rep:
|
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
|
|
|
09-01-2014, 10:05 AM
|
#2
|
Senior Member
Registered: Nov 2004
Distribution: Mint, MX, antiX, SystemRescue
Posts: 2,337
|
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.
|
09-01-2014, 10:34 AM
|
#3
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
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.
|
|
|
09-01-2014, 12:55 PM
|
#4
|
Member
Registered: Feb 2011
Location: Wales
Distribution: MX Linux 18
Posts: 36
Original Poster
Rep:
|
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 12:57 PM.
Reason: to add 2 words
|
|
|
09-01-2014, 01:27 PM
|
#5
|
Senior Member
Registered: Nov 2004
Distribution: Mint, MX, antiX, SystemRescue
Posts: 2,337
|
Quote:
Originally Posted by lwv962
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.
|
09-01-2014, 04:50 PM
|
#6
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
Quote:
Originally Posted by lwv962
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.
|
09-01-2014, 05:02 PM
|
#7
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
Quote:
Originally Posted by haertig
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 
|
|
|
09-01-2014, 05:48 PM
|
#8
|
Senior Member
Registered: Nov 2004
Distribution: Mint, MX, antiX, SystemRescue
Posts: 2,337
|
Quote:
Originally Posted by keefaz
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.
|
|
|
09-01-2014, 06:45 PM
|
#9
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
Good point, thanks for clarify
Quote:
Originally Posted by haertig
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.
|
09-02-2014, 09:33 AM
|
#10
|
Member
Registered: Feb 2011
Location: Wales
Distribution: MX Linux 18
Posts: 36
Original Poster
Rep:
|
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 ?
|
|
|
09-02-2014, 09:43 AM
|
#11
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
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>
|
|
|
09-02-2014, 10:14 AM
|
#12
|
Member
Registered: Feb 2011
Location: Wales
Distribution: MX Linux 18
Posts: 36
Original Poster
Rep:
|
Hi keefaz,
Quote:
export DISPLAY=:0.0
source /home/peter/.bashrc
cadno
<eot>
|
No luck with this !
Any ideas ?
|
|
|
09-02-2014, 11:01 AM
|
#13
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
Can you post your .bashrc file or it's secret?
|
|
|
09-02-2014, 12:22 PM
|
#14
|
Member
Registered: Feb 2011
Location: Wales
Distribution: MX Linux 18
Posts: 36
Original Poster
Rep:
|
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 ?
|
|
|
09-02-2014, 12:39 PM
|
#15
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,797
|
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
}
|
|
|
All times are GMT -5. The time now is 09:04 AM.
|
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
|
|