Schedule a command with 'at'
Hi,
I'm trying to run a command with the 'at' scheduler in Linux Mint 9. It's basically a ssh connection to my Smoothwall firewall to tell it to shut down, but that part isn't really important. The problem I have is that I can't get the 'at' schedule command to do much. I can type commands into the terminal and they work perfectly. If I enter exactly the same command into 'at' nothing happens. For example, I can type 'plink -load smoothwall' into a terminal and a new ssh terminal comes up asking for my password to make an ssh connection. If I create an 'at' job with the same command, ie: Code:
$ at now + 5 minutes I've checked that the job exists by doing an 'atq' command. Obviously there's something about 'at' that I don't understand. I've googled, I've looked in this forum and I've looked in a copy of 'The Linux Bible 2010' all without success. I've tried various alternative ways of entering the command for a couple of hours and I'm still stuck. Help! |
Hi,
Check if atd is running: Code:
ps -ef|grep atd |
Thanks for the quick response.
Quote:
Code:
daemon 1321 1 0 13:31 ? 00:00:00 atd |
The problem may be that you're attempting commands such as ssh that require password authentication. When "at" commands are executed, there's no terminal associated with the command, so there's no way for the commands to request a password.
From the at man page: Quote:
|
Hi,
Please check that your command executes from your shell without using at. If you get success in this, specify the command in a file & use -f , -c , -t paramter with at command. Regards, Devendra Koli |
Quote:
So it's: Code:
plink -load smoothwall -log putty.log -pw <password> -m ~/shutdown.txt Quote:
|
Quote:
|
OK, I think I misunderstood what command you wanted to do.
So you want to use plink from a windows machine to ssh into a linux box and then use "at" to schedule some task in the future. Is that right? I'm not too familiar with plink, but assuming the above is true, perhaps you should create a script on the remote machine and use the -f option to run your commands from a file. so if you have a command file like shutdown.txt, you can tie this file into the at command: Code:
at now + 5 minutes -f ~/shutdown.txt |
The problem is also because I don't know what sort of commands 'at' can work with. For example, I can type 'gcalctool' in a terminal and up pops the gnome calculator. If I set up 'at' to run the same command, nothing happens.
Why is that? The reason for failure to run gcalctool probably relates to why my other commands don't work. |
Quote:
|
"gcalctool" needs a display to run so it won't run with "at". You will probably find that you have mail in /var/spool/mail/username which will give you the output from your "at" command. This may give you some extra insight into why your commands are not working via "at".
|
Quote:
|
I was able to get a simple test to work using plink and at. Here's what I did. I saved the plink command in a local file, plink.txt
Code:
plink user@server -pw <password> 'echo hello > /tmp/1234.txt' Code:
$ at now +2 minutes -f plink.txt |
Ok, this is just getting weird!
It's now working - using exactly the same plink command that wasn't working fifteen minutes ago. I've tested it three times in a row, and it's shutting down the firewall exactly on cue. I've been copying and pasting the command since I started, so I know it's not due to any improvement in my typing ability. Now I'm really baffled. Do I mark this as 'solved' - or just plain odd? |
All times are GMT -5. The time now is 12:06 PM. |