Sponsored Content
Top Forums Shell Programming and Scripting Working with files that are named with a timestamp Post 302740781 by os2mac on Thursday 6th of December 2012 06:53:23 PM
Old 12-06-2012
Found my own solution.

This is my fault, I always forget to mention distro. This is Solaris 10. As such it doesn't have the mmtime switch in find.

What it does have is -newer that compares the results against the mtime of the file called out after the -newer switch is set.

so
Code:
DATE=`date +'%y%m%d%H'`
NEWER=/users/userid/.newer
LOG=/users/userid//sftp.log
HOSTIS=`hostname`
#EMAIL NOTIFICATION ALS
#EMAIL=user@domain.com

if [ $HOSTIS = 'hostname' ]; then
  TOHOST='user@domain.com'
 else
#This is for the validation server
 TOHOST='user@domain.com'
fi


for i in `find /transfer -name '*.txt' -newer $NEWER -print `
do
   sftp  $TOHOST <<EFT
   cd /inbound/dir
      lcd /transfer
      put $i

EFT
   touch -a -m $NEWER;
   echo "SFTP Completed successfully." |mailx -s " SFTP completed successfully" $EMAIL
exit
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Comparing files named by date/time

I've looked at several of the previous posts and can't seem to find any that pertain to my problem, I'd appreciate some help if possible. I have a directory with numerous logs of various names all named by heading and date ie. dog.20050529.log dog.20050530.log ... (2 Replies)
Discussion started by: gillr
2 Replies

2. UNIX for Dummies Questions & Answers

fifo or named pipe working?

Can someone explain to me the working of fifo() system call using simple C programs so that I can implement them in the UNIX environement? (1 Reply)
Discussion started by: lvkchaitanya
1 Replies

3. Shell Programming and Scripting

Finding missing files that are named sequentially with Perl?

Hello I am new to Perl, in fact I am on chapter one of the book. :) However I am in need of a Perl Script faster than I can finish the book. Perhaps someone can help me with my immediate need while I read my book. I have a directory with hundreds of files that are all named like... (4 Replies)
Discussion started by: newftronics
4 Replies

4. Shell Programming and Scripting

cat certain files in directories to files named after the dir?

Hi all, I have a directory with many subdirectories each named like so: KOG0001, KOG0002, ...KOG9999. Each of these subdirectories contain a variable number two kinds of files (nuc and prot) named like so: Capitella_sp_nuc_hits.fasta (nuc) and Capitella_sp_prot_hits.fasta (prot). The... (2 Replies)
Discussion started by: kmkocot
2 Replies

5. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

6. Shell Programming and Scripting

Move all files not in a directory into a subdirectory named for each given file

Hi Everyone! Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file. Any ideas? Thank you! (1 Reply)
Discussion started by: DanTheMan
1 Replies

7. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

8. Shell Programming and Scripting

Joining Similarly Named Files

Have a few hundred files that I have no control over. I need to join them on a common string. There are two files per unit. The file names are: AAAA_X_file1.txt AAAA_file2.txt join -a1 file1 file2 - this works. My question is, is there a way to use the join command listing the file... (4 Replies)
Discussion started by: jimmyf
4 Replies

9. Shell Programming and Scripting

[Solved] awk manipulation of sequentially named files

Hello, I am a very novice user of awk, I have a set of files named file001, file002, file003, file004, etc., each contains four fields (columns of data) separated each by a uneven number of spaces. I want to substitute those spaces by a TAB, so I am using this line of awk script: awk -v OFS="\t"... (4 Replies)
Discussion started by: jaldo0805
4 Replies

10. Shell Programming and Scripting

How to zip or rm the multi part named files?

Hello There, There are more than 1000 files in my log folder and i want to zip it to relase the space. But my method throwing syntax error due to the multi part file name, how to overcome in this ? ls -lart | grep "MDB_Kernel11.1_gwlog_SUN 22_09_2013" | awk '{print $9,$10,$11,$12}' | head... (8 Replies)
Discussion started by: gowthamakanthan
8 Replies
ANACRON(8)						       Anacron Users' Manual							ANACRON(8)

NAME
anacron - runs commands periodically SYNOPSIS
anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [job] ... anacron -u [-t anacrontab] [job] ... anacron [-V|-h] DESCRIPTION
Anacron can be used to execute commands periodically, with a frequency specified in days. Unlike cron(8), it does not assume that the machine is running continuously. Hence, it can be used on machines that aren't running 24 hours a day, to control daily, weekly, and monthly jobs that are usually controlled by cron. When executed, Anacron reads a list of jobs from a configuration file, normally /etc/anacrontab (see anacrontab(5)). This file contains the list of jobs that Anacron controls. Each job entry specifies a period in days, a delay in minutes, a unique job identifier, and a shell command. For each job, Anacron checks whether this job has been executed in the last n days, where n is the period specified for that job. If not, Anacron runs the job's shell command, after waiting for the number of minutes specified as the delay parameter. After the command exits, Anacron records the date in a special timestamp file for that job, so it can know when to execute it again. Only the date is used for the time calculations. The hour is not used. When there are no more jobs to be run, Anacron exits. Anacron only considers jobs whose identifier, as specified in the anacrontab matches any of the job command-line arguments. The job argu- ments can be shell wildcard patterns (be sure to protect them from your shell with adequate quoting). Specifying no job arguments, is equivalent to specifying "*" (That is, all jobs will be considered). Unless the -d option is given (see below), Anacron forks to the background when it starts, and the parent process exits immediately. Unless the -s or -n options are given, Anacron starts jobs immediately when their delay is over. The execution of different jobs is com- pletely independent. If a job generates any output on its standard output or standard error, the output is mailed to the user running Anacron (usually root). Informative messages about what Anacron is doing are sent to syslogd(8) under facility cron, priority notice. Error messages are sent at priority error. "Active" jobs (i.e. jobs that Anacron already decided to run and now wait for their delay to pass, and jobs that are currently being exe- cuted by Anacron), are "locked", so that other copies of Anacron won't run them at the same time. OPTIONS
-f Force execution of the jobs, ignoring the timestamps. -u Only update the timestamps of the jobs, to the current date, but don't run anything. -s Serialize execution of jobs. Anacron will not start a new job before the previous one finished. -n Run jobs now. Ignore the delay specifications in the /etc/anacrontab file. This options implies -s. -d Don't fork to the background. In this mode, Anacron will output informational messages to standard error, as well as to syslog. The output of jobs is mailed as usual. -q Suppress messages to standard error. Only applicable with -d. -t anacrontab Use specified anacrontab, rather than the default -V Print version information, and exit. -h Print short usage message, and exit. SIGNALS
After receiving a SIGUSR1 signal, Anacron waits for running jobs, if any, to finish and then exits. This can be used to stop Anacron cleanly. NOTES
Make sure that the time-zone is set correctly before Anacron is started. (The time-zone affects the date). This is usually accomplished by setting the TZ environment variable, or by installing a /usr/lib/zoneinfo/localtime file. See tzset(3) for more information. FILES
/etc/anacrontab Contains specifications of jobs. See anacrontab(5) for a complete description. /var/spool/anacron This directory is used by Anacron for storing timestamp files. SEE ALSO
anacrontab(5), cron(8), tzset(3) The Anacron README file. BUGS
Anacron never removes timestamp files. Remove unused files manually. Anacron uses up to two file descriptors for each active job. It may run out of descriptors if there are more than about 125 active jobs (on normal kernels). Mail comments, suggestions and bug reports to Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>. AUTHOR
Anacron was originally conceived and implemented by Christian Schwarz <schwarz@monet.m.isar.de>. The current implementation is a complete rewrite by Itai Tzur <itzur@actcom.co.il>. The code base is currently maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>. Sean 'Shaleh' Perry 2000-06-22 ANACRON(8)
All times are GMT -4. The time now is 09:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy