How to use 'nohup' and 'at' commands collectively?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to use 'nohup' and 'at' commands collectively?
# 1  
Old 04-07-2011
How to use 'nohup' and 'at' commands collectively?

I have a unix script named 'test1' and it can be run using parameters say a, b and c. i.e. the command would be
Code:
test1 -a -b -c

this script gives the output in the log file as
Code:
script started
start time: 10.22 pm 7 april
end time: 10.30 pm 7 april
script finished

Now, i want to run this batch at some later time. say i want to run it at 2:00 am in the night when no one is there in the office. so i am giveing the command as
Code:
nohup at -f `test1 -a -b -c` 2 am 08april

I fire this command and close the session. The next day when i come to the office I see that the log file is showing me below output
Code:
script started
start time: 10.22pm 7 april

Thus the script starts as soon as fired and it stops running as soon as i close the session.

please help me in resolving this. please also let me know if my issue is not clear.

regards,
Swapnil

Last edited by Scott; 04-08-2011 at 04:04 PM.. Reason: Please use code tags for code, data files, terminal output, etc.
# 2  
Old 04-07-2011
A few things.
  1. By putting it in backticks, you're running this 'test1' command immediately.
  2. -f doesn't take parameters and doesn't take commands. It takes a bourne script file and nothing but a bourne script file.
  3. nohup is redundant here, running something by at instead is at least as good as it by itself. 'at' doesn't stick around. The command just hands off your request to the at daemon then quits. the at daemon itself will run the command later, quite independent of your own session.
  4. Without the full path, it may have no idea where test1 is. It may not have the full PATH you're used to so specify an absolute path.

Fortunately you can avoid having to create a script file to feed it a command in. Try:

Code:
echo '/path/to/test1 -a -b -c' | at 2am 08 april

It's usually not a good idea to name scripts 'test'. There's already a 'test' command that you don't want it confused with.

Last edited by Corona688; 04-07-2011 at 03:19 PM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 04-08-2011
I tried with the given command but it is giving the error as 'date is not in the correct format'.
I also tried with the below commands:
Code:
echo 'autobatch -bl -bc'|at 5:10 pm 08 april
echo 'autobatch -bc -mand'|at 5:10pm 08april2011
echo 'autobatch -bc -mand'|at 5:10pm today
echo 'autobatch -bc -mand' | at 05:10pm today
echo `autobatch -bc`|at 5:10pm today
echo 'autobatch -bc'|at 05 pm 08 april
echo 'autobatch -bc'|at 5:10pm 8april
echo 'autobatch -bc'|at 5:10pm 8 april 2011

but its giving the syntax error.

please help me in this.

Last edited by Scott; 04-08-2011 at 04:04 PM..
# 4  
Old 04-08-2011
Code:
echo 'autobatch -bl -bc'|at 5:10 pm 08 april

should work fine. Does it give the same error or something else?

I also note you're not giving the complete path like I suggested. echo '/path/to/autobatch -bl -bc' | at ...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Execute Oracle pl/sql commands in a scrit using nohup

Good afternoon: I need your help please, Im new at Unix nd specially Unix applicationas like oracle and Ive got this problem: I was asked to execute the next script using nohup in order to not hang up the session because it was supposed to connect to the database and then insert about 2... (3 Replies)
Discussion started by: alexcol
3 Replies

2. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

3. UNIX for Dummies Questions & Answers

Nohup

Hi Every one , i wrote a script for nohpu ,which checks the service by using the port number and starts if it doesnt hear the port. It works good untill i colse the session. how to make it work even after closing the session .And aslo how to deamoize this script #!/bin/bash netstat -ptlen |... (2 Replies)
Discussion started by: vikatakavi
2 Replies

4. AIX

HACMP: difference between 'cl' commands and 'cli' commands

Hi all, I'm new in this forum. I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli". The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory. I know that the first are called HACMP for AIX... (0 Replies)
Discussion started by: peppix
0 Replies

5. Shell Programming and Scripting

using nohup with set of commands

hi I want to use nohup command with set of commands .. my goofy sample : nohup while true do ; date; done and its not working . any idea ? cheers (1 Reply)
Discussion started by: kvok
1 Replies

6. Shell Programming and Scripting

using mutiple "nohup" to execute multiple commands.

I need to run multiple commands on remote server using the nohup... I have tried 2 options 1) rsh <SERVER_NAME> -n "nohup perl $SCRIPTS_DIR/abc.pl ; $SCRIPTS_DIR/xyz.ksh & " & 2) rsh <SERVER_NAME> -n "nohup perl $SCRIPTS_DIR/abc.pl & nohup $SCRIPTS_DIR/xyz.ksh & " & I need to know if... (2 Replies)
Discussion started by: aster007
2 Replies

7. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

8. Filesystems, Disks and Memory

killing nohup commands delete files?

Hello, I just want to ask if killing a specific procees might delete files being read of that process? Here is the scenario: I execute nohup find . -type f |xargs ls -lrt > nohup1.out & I noticed that it is taking so much space, I check that there are files so huge .nfs* and keep on... (2 Replies)
Discussion started by: james_falco
2 Replies

9. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies

10. UNIX for Dummies Questions & Answers

"nohup" and "&" commands

Why would anyone ever type in a command like this: nohup command & nohup lets you logout of your telnet session so why add "&" to run it in the background? (1 Reply)
Discussion started by: xadamz23
1 Replies
Login or Register to Ask a Question

Featured Tech Videos