LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2014, 07:27 PM   #1
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Rep: Reputation: Disabled
Angry Solaris at command


Hello all,

I have a very frustrating problem and I would be very very very grateful if someone can find a solution for me. I am trying to run a script at a later time in the day, after I have logged out of the Solaris OS. So far, I've discovered the "at" command and believe this is my answer, however, when i try to run a custom script with the at command it shows that it was put in the queue but it never runs the script. Now....if i run a regular command like "reboot" or "firefox" the at command executes it just fine. I have triple checked to make sure that at.deny and at.allow both are setup so that I can run it as a root user. Can someone please help? Below, I've listed a simple script that i can not get to run with the at command. Thanks guys!!

#! /sbin/sh
df -k
exit 0
 
Old 08-09-2014, 09:51 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 556

Rep: Reputation: 198Reputation: 198
It's not clear from your post if you have checked your mail.

From the "at" man page
Quote:
The user will be mailed standard error and standard output from his commands, if any.
 
Old 08-09-2014, 10:01 PM   #3
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
The at command only executes 1 time unless you set it up with multiple instances.http://en.m.wikipedia.org/wiki/At_(Unix)
Cron is probably what you want. That's just my assumption, as I haven't used either.
 
Old 08-09-2014, 10:48 PM   #4
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
It does send mail and the mail says that it ran but it must of ran in the background because I never saw a terminal window pop up like the script is supposed to do?
 
Old 08-10-2014, 11:32 AM   #5
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,088

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by mikeneedshelp View Post
It does send mail and the mail says that it ran but it must of ran in the background because I never saw a terminal window pop up like the script is supposed to do?
Why would a terminal window pop up? How would that work if you weren't logged in? As previously stated the "The user will be mailed standard error and standard output from his commands, if any." Also from man page on Solaris 11.1:

Quote:
-m Sends mail to the invoking user after the
at-job has run, announcing its completion.
Standard output and standard error produced
by the at-job are mailed to the user as
well, unless redirected elsewhere. Mail is
sent even if the job produces no output.

If -m is not used, the job's standard output
and standard error is provided to the user
by means of mail, unless they are redirected
elsewhere; if there is no such output to
provide, the user is not notified of the
job's completion.


Also Solaris isn't Linux. Solaris doesn't ship with the same userland stuff that Linux distros do and a lot of stuff behaves differently on Solaris and Linux. I don't know how, if at all, at differs but I wouldn't assume it behaves the same. I was going to say you might do better to post in the Solaris sub-forum here but that has very few posts in it. You might do better to seek help in a Solaris forum e.g. http://www.unix.com/solaris/
 
Old 08-10-2014, 12:06 PM   #6
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
This is correct, but even while logged in, it will not display the outcome. Also on a side not, if I wanted to run a script with the "at" command and the script prompts for a yes or no, is there a way to set the "at" To answer yes or am I going to have to take the prompting out of the script? I will also try the link you provided for the solaris forum. Thanks!!
 
Old 08-10-2014, 12:11 PM   #7
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,088

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by mikeneedshelp View Post
This is correct, but even while logged in, it will not display the outcome.
No, it won't. That's not how at works.


Quote:
Originally Posted by mikeneedshelp View Post
Also on a side not, if I wanted to run a script with the "at" command and the script prompts for a yes or no, is there a way to set the "at" To answer yes or am I going to have to take the prompting out of the script?
If you want to run a script non-interactively it would be better for it to not require user input. If it really must require user input then depending on how the script works the solution may be as simple as
Code:
$ echo yes | thescript
Or look at the expect command. http://en.wikipedia.org/wiki/Expect It's on the Solaris 11.1 machine I have access to, no idea if it's installed by default.
 
Old 08-10-2014, 12:25 PM   #8
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
So if I wanted the "at" command to...let's say...run a script that will prompt for yes, reset certain data back to default and then do a server reboot at a later time in the day, unattended would "at" have the capability of doing this?
 
Old 08-10-2014, 02:09 PM   #9
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,088

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by mikeneedshelp View Post
So if I wanted the "at" command to...let's say...run a script that will prompt for yes, reset certain data back to default and then do a server reboot at a later time in the day, unattended would "at" have the capability of doing this?
No. at has the capability to run a specified command at a specified time. If that commands requires input you need to figure out how to call the command in a way that ensures that input is provided. E.g. You have a script called myscript that requires a value of yes or no to be provided via stdin. If you want myscript to be called by at with an input value of yes you could create a wrapper script called call_my_script_yes that contain
Code:
echo yes | myscript
then you tell at to run call_my_script_yes.


As EDDY1 has already suggested, it's possible that what you actually want is cron.
 
1 members found this post helpful.
Old 08-10-2014, 02:13 PM   #10
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
That's all easily doable except for the prompting for yes jobs. The at daemon, as the name implies, is a daemon so it does not have a controlling terminal or any easy way to get access to one. This is why you never see a terminal window pop up, even if you are logged in. I suppose you could try to read/write directly to /dev/console, which would work if you're running the script as root, which you may need to do at least to reboot the system, depending on whether Solaris has the ability to delegate shutdown priveliges via something like /etc/shutdown.allow (it's been several years since I last touched at Solaris machine, unfortunately, so my memory is a bit rusty). Another option would be to used something like a Unix domain socket or a named pipe (mkfifo) to communicate with another program that has access to a pty. That seems kind of hackish to me, though.

Would it be possible to have the script check for the presence of a file, e.g. /var/tmp/oktoshutdown, and not shut down the system unless it was there? That seems easier to accomplish versus trying to prompt for a human to respond to input (at jobs are meant to run unattended).

Also, as mentioned above, unless you set your shell script to throw itself back into the at queue, it will only run once. Other have suggested cron, which would probably work better if you need to do this repeatedly.
 
Old 08-11-2014, 12:01 PM   #11
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
I was debating cron but it will only run on a broad fixed schedule where as "at" will run on a more "specific" time. Like if someone requests me to do a reboot at different times throughout the day, then I can go in and have "at" run several reboots unattended at random times of the day. As far as the prompt for yes or no....I may have to work it out of the script, as the script really doesn't need it since I only run the script as needed and it is always a yes anyway. I've tried removing the yes prompt in the past and when I run the script I get errors that read "error line 233"???

Last edited by mikeneedshelp; 08-11-2014 at 12:20 PM.
 
Old 08-11-2014, 12:03 PM   #12
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
Also....as of now it is a shell script with the little shell icon. How can I turn it into an executable (with the lightning bolt)? I've used chmod to change it and it keeps changing it to the shell icon??? Again, running the reboot command..."at" has no issues, I don't even have to specify a path but the command "reboot" is an executable not a shell, could this be an issue???

Last edited by mikeneedshelp; 08-11-2014 at 12:10 PM.
 
Old 08-11-2014, 12:38 PM   #13
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,088

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by mikeneedshelp View Post
I've tried removing the yes prompt in the past and when I run the script I get errors that read "error line 233"???
It's impossible to say what the error is based on that error message. I suspect that's not actually the error you got but a paraphrased version of it.


Quote:
Originally Posted by mikeneedshelp View Post
Also....as of now it is a shell script with the little shell icon. How can I turn it into an executable (with the lightning bolt)? I've used chmod to change it and it keeps changing it to the shell icon??? Again, running the reboot command..."at" has no issues, I don't even have to specify a path but the command "reboot" is an executable not a shell, could this be an issue???
I don't understand what issue you are describing other than you seem to think the icon is somehow relevant, which it really isn't. You set permissions with chmod, check them with 'ls -l filename'. You don't say what you did with chmod.
 
Old 08-11-2014, 01:11 PM   #14
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
I used chmod to make it an executable but if you say that the icon doesn't matter than I trust your judgment! The next time I'm around the server, I will remove the prompt for yes and copy verbatim what the error reads when I try and run the script. I believe (and quote me if I'm wrong) that when I remove lines from the script, the spacing my be off inside the script? I've tried to remove the lines and keep the spacing but it will still error out? I also believe that to remove the prompt there are two lines, one in the beginning and one near the end of the script, correct??
 
Old 08-13-2014, 01:02 PM   #15
mikeneedshelp
LQ Newbie
 
Registered: Aug 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
Ok...I've managed to delete the prompting out of the script and now I just need to see if it will run with the at command. I'll keep you guys posted, again thanks!!
 
  


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
Solaris 10 and TRIM command sluge Solaris / OpenSolaris 1 01-31-2014 05:28 PM
stat command on Solaris devUnix Solaris / OpenSolaris 7 03-18-2012 05:14 AM
swap -a command in solaris balakodoth Linux - Newbie 6 01-03-2011 10:36 PM
cu command to solaris wimnat Linux - Networking 0 11-03-2005 03:05 AM
How to use cron command in solaris meng_en General 1 11-06-2002 09:08 PM


All times are GMT -5. The time now is 04:07 PM.

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