Setting the date.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting the date.
# 1  
Old 07-12-2010
Setting the date.

I am modifying some script and need to have the script reflect the current date. I have the script below. In the section yy="2010",mm="07", dd="12" What would I need to change to have the script automatically input the current year month & date instead of manually updated the script daily?

Code:
  
  yy="2010"
  mm="07"
  dd="12"

 

  for hh in 00 06 12 18; do

      

      ${PGM}/file -i${dir}/file2_${yy}-${mm}-${dd}_${hh}:00:00 

      cat file.BIN >> file2km.${yy}${mm}${dd}00

  done 
  rm -f FILE.BIN


Last edited by libertyforall; 07-31-2010 at 01:25 AM.. Reason: Code tags, please...
# 2  
Old 07-12-2010
Code:
  PGM="/share/apps/hysplit/exec"
  dir="/share/huina/rhuff/hysplit/wrf"

  eval$(date '+yy=%Y mm=%m dd=%d')
  #yy="2010"
  #mm="07"
  #dd="12"

# 3  
Old 07-12-2010
How exactly would I write that? Would I eliminate
Code:
  #yy="2010"
  #mm="07"
  #dd="12"

and simply write

eval$(date '+yy=%Y mm=%m dd=%d')

Or would I write

#yy=%Y
#mm=%m
#dd=%d

Is there any reason why Y is uppercase?

Last edited by libertyforall; 07-31-2010 at 01:31 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies

3. Solaris

Setting Date Variable +1 date

I need to set a date varable within ksh that will set the date to the next day in the format 25-JUL-2013 - any help would be appreciated. (3 Replies)
Discussion started by: bjdamon
3 Replies

4. Solaris

Crontab date setting problem

Hi, i wanted to schedule a backup script to run on 7.30pm every 1st Sat of month MAR, APR, SEP, OCT. Am i understanding it correctly? Because it doesn't seem to run according to the schedule i needed. = (7.30pm) & (1st to 7th day of the month) & (MAR, APR, SEP, OCT) & (Sat) 30 19 1-7... (1 Reply)
Discussion started by: beginningDBA
1 Replies

5. Solaris

Crontab date setting problem

Hi, 0 9 1,2,3,4,5,6,7 3,4 6 I want a cronjob to run on every 1st Sat of Mar & Apr. But the above schedule is running is running on the 1st 7 days. How do i rectify it? Thanks in advance. (2 Replies)
Discussion started by: beginningDBA
2 Replies

6. UNIX for Advanced & Expert Users

Setting up complex Date conditions in Autosys

Scenario : Job A - to be started at 2230 PM everyday ( mo-fr ) Job B - Need to start after 4 hours Jobs A started,irrespective of the Jobs A status .Even if Job A has failed/Succeeded/Terminated/Running Job B should start 4 hours after Job A started.It cannot be set to 0230 AM next day because... (2 Replies)
Discussion started by: krg.sati
2 Replies

7. Solaris

setting date format in solaris

Hi, i just want to know how to format date command in solaris. like in linux if i use `date +%s`, it gives me seconds since 1970, but in solaris (sol86) , it is giving %s as result. Is there any different way in solaris Thanks Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

8. UNIX for Dummies Questions & Answers

setting the system date

Okay so I'm not really a newbie, but this bugs the crap out of me (rant on). Every so often I need to change the system time. I run "man date" and always find the "date -s" command, but for who knows how long, the manual page has *never* listed the format of the input string required to set the... (1 Reply)
Discussion started by: qneill
1 Replies

9. Programming

Setting Environment Variable date

Hi to all... I'm currently running a C++ program in Unix environment and it is dependent to a Unix environment variable with a date value. ex: echo $DateToday 20060403 I want to change that date in my C++ program, changing the value date to 20061120 and revert back to original... (6 Replies)
Discussion started by: d3ck_tm
6 Replies

10. UNIX for Dummies Questions & Answers

setting date and time

how do i set the system date and time? i know i have to be root to do it but i'm new to unix--really new--and some of this stuff seems really cryptic. thanks for any help.:confused: (2 Replies)
Discussion started by: singlefin
2 Replies
Login or Register to Ask a Question