osx - Execute command in script based on year -


i have powerbook dead laptop battery... everytime disconnect it's power source date gets set year 1969. leads issues network authentication, keychain access, etc. wrote launch daemon executes script in order set date more appropriate @ boot, works fantastically.

  #!/bin/bash    date 0101122014 

now want run if year 1969, way if time correct won't set @ all.

so like...

  #!/bin/bash    year="date +%y"    if [ $year = 1969 ] ;   date  010112002014    else exit 0   fi 

i know syntax totally off, it's give idea of want do. in advance.

use command substitution:

year=$(date +%y) 

or even:

[ $(date +%y) = 1969 ] && date 010112002014 

or, using if:

if [ $(date +%y) = 1969 ] date 010112002014 fi 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -