Executing a job with file success


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Executing a job with file success
# 1  
Old 08-02-2017
Executing a job with file success

Hello All,

I have a scenario where I need suggestion

I am creating a file watcher job on autosys and and command job to do a SCP a file from one server to another. My file watcher will get success once the file get receive. The file I am receiving a zip file. THe command job which I am running will be running every 10 min to receive the file from the server. Now I am not sure what will happen the SCP job triggered when the zip file is halfdone. Is there a way that I can do a check for the zip to make sure it is completed .

Thanks
Arun
# 2  
Old 08-02-2017
The only reliable way to do this is to have the uploader inform you when it is done. Often this is done by using sftp(same network protocol as scp) to first put the file into an 'uploads' folder, then mv it to the real destination somewhere in the same partition. This guarantees that only 100% complete files will appear for your file watcher.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 08-02-2017
Have the scp process send two files, the first the actual data file, and the second a small (20 bytes) file. Whenever the second file exists, you will know that the large data file has been received completely.
# 4  
Old 08-07-2017
I take it you are worried about finding the file while it is in the process of being transferred?

If you are using scp with a key you could consider using a trigger script which would be able to process the file once the transfer is complete.

authorized_keys:
Code:
command="/path/to/script" key

In the script:
Code:
if [[ ${SSH_TTY:-unset} == "unset" ]]
then
   cmd=${SSH_ORIGINAL_COMMAND%% *}
   case ${cmd} in
      scp) declare -a cmd_args=(${SSH_ORIGINAL_COMMAND#* })
           pre_scp ${cmd_args[*]}       # find existing files
           scp ${cmd_args[*]}           # perform scp
           post_scp ${cmd_args[*]}      # find new files
           ;;
   esac
fi

So the SSH_TTY variable is set for an interactive shell; you have effectively disabled using this key for interactive sessions - a bonus if this is used with a passphrase-free key pair. The pre_scp and post_scp commands are shell functions defined elsewhere in the script to identify the file(s) being copied. The post_scp function could then run the alert.

Be aware that using this will hold the scp session on the client side open; you may wish to fork a process in the post_scp function.

Andrew
# 5  
Old 08-07-2017
You can test the zip archive, exit code ($?) should be zero on good file.
Code:
unzip -qtl archive.zip && printf "%s\n" "File is fine do the job.."

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logging success event into file

Hi, I've the following code to log the errors any after the command is executed. # Ksh 88 Version log_path=/home/etc/fls/fls_log.log del_path=/home/etc/fls/to_day rm $del_path/* >> $log_path 2>&1 But I even want to log if the rm command is success without any error along with... (1 Reply)
Discussion started by: smile689
1 Replies

2. Shell Programming and Scripting

How to write SCP success or failure to a file

Does anyone know how to write the results (success and failure) to a file. I am using TCSH on a Solaris machine. I have the following code for a successful SCP...could someone help me add to this so it caputres failures also? CODE SO FAR (received from a previous post): scp sourcefile.txt... (3 Replies)
Discussion started by: thibodc
3 Replies

3. UNIX for Dummies Questions & Answers

Executing python scripts via cron job

Hi, I'm executing a python script via cron job. The way it is set up is, I'm editing a file called local00 22 * * * root su - -c "/opt/setup_dir/bin/run_bkp -p" When this job executes, the command-specific logfile and the syslog (where the logs are supposed to go) show half of the logs(no... (2 Replies)
Discussion started by: ashwini.engr07
2 Replies

4. Shell Programming and Scripting

adding data in input file if 2nd script output SUCCESS

Hi All, how can i edit my original data and add more data if my 2nd script outputs SUCESS? ex. input file: 1.txt nik,is,the 1script.sh if 2ndscript.sh output SUCCESS then i'm going to edit my input file and add data best,pogi.. sample outputdata. nik,is,the,best,pogi 2ndscript.sh... (3 Replies)
Discussion started by: nikki1200
3 Replies

5. Shell Programming and Scripting

Curl ftp upload success but no file exist on the server !!!!

hello, I'm trying to upload a file to this ftp server and others ftp://ftp.byethost12.com as you can see in the output of CURL using the -v option curl reports that the upload succeeded but when i connected to the server with file-zilla there is no file uploaded the same command upload files... (5 Replies)
Discussion started by: laraaj
5 Replies

6. Shell Programming and Scripting

NDM process say success but file didn't reach destination

I am using ndmcli to NDM my files. When i do so it prints success for the process, with out any errors, but file is not reached at destination. ndmcli -x << EOJ submit phcdb process snode=$RMT_NODE_NAME step01 copy from (file=$SRC_FILE_NAME pnode) to (file=$DST_FILE_NAME snode... (0 Replies)
Discussion started by: pattamuthu
0 Replies

7. Shell Programming and Scripting

Cron job not executing

I need to add 10 records to database from a file /tmp/authlist.log(contains insert into table sql commands) When i execute the following script manually its executing and working fine. the same is not getting executed when i try to execute using crontab vi /tmp/test1.sh #!/bin/sh... (4 Replies)
Discussion started by: kalyankalyan
4 Replies

8. UNIX for Dummies Questions & Answers

nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background. nohup perf_mon -c rating_4_multi,cfg & The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I... (2 Replies)
Discussion started by: ido1957
2 Replies

9. UNIX for Dummies Questions & Answers

Problem with executing command inside a cron job

Hi All, I have scheduled a script in cron which writes output to the below file. ....>> /data/Target/wrapper_invoke_ds_job_`date '+%Y%m%d'`.ksh_out 2>&1 But the date command is not getting resolved in the format specified. It just resolves to the following. wrapper_invoke_MQ_ds_job_Tue... (3 Replies)
Discussion started by: pkm_oec
3 Replies

10. Shell Programming and Scripting

how to exit with success if the file is not found

I want to put a exit if there is no file found. In the directory I can have multiple txt files with EPISGCHGS as prefix or maynot have one. When I am trying the following it is erroring if there is no text file with the EPISGCHGS as prefix. for file in EPISGCHGS*.txt do cat $file >... (2 Replies)
Discussion started by: apps_user
2 Replies
Login or Register to Ask a Question