03-23-2012
It doesn't need bash specifically, by the way.
What it does need is a modern version of GNU date, so if you take this script to a Solaris or AIX or other such system it won't work.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
Can unix cshell list out the number of days between 070201 and 070205 (format is yymmdd) and list out all the dates in between in similiar format.
set startdate = `date '+%y%m%d'` #eg 070201
set enddate = `date '+%y%m%d'` #eg 070205
i would expect the number of days to be 5... (2 Replies)
Discussion started by: Raynon
2 Replies
2. UNIX for Advanced & Expert Users
Hi
I'm looking for a .ksh script/function that will calculate ONLY the number of days between two distinct dates. Further convert the number of days to weeks and display. I need this to be part of another larger script that checks the password expiry on several servers and notifies the... (1 Reply)
Discussion started by: radheymohan
1 Replies
3. Shell Programming and Scripting
does any one have any ideas how i would go about calculating the number of days left in the month from a bash script ?. I want to do some operations on a csv file according to the result (8 Replies)
Discussion started by: dunryc
8 Replies
4. Shell Programming and Scripting
I need a script to figure out if a user's last login was 90 days or older. OS=AIX 5.3, shell=Korn
Here's what I have so far:
====
#!/usr/bin/ksh
NOW=`lsuser -a time_last_login root | awk -F= '{ print $2 }'`
(( LAST_LOGIN_TIME = 0 ))
(( DIFF = $NOW - $LAST_LOGIN_TIME ))
lsuser -a... (3 Replies)
Discussion started by: pdtak
3 Replies
5. Shell Programming and Scripting
Hi Guys,
I was working some time ago n was in need to calculate date 30/31 days from today including Feb (Leap yr stuff). Today date is variable depending on day of execution of script. I tried searching but was not able to get exactly what I needed....So at that I time I implemented by my own... (3 Replies)
Discussion started by: coolgoose85
3 Replies
6. Shell Programming and Scripting
Hi
I need one single command to get number of days between
two given dates.datecalc is not working.
ex.
fromdate:01.04.2010
todate :24.04.2010
i should get the out put as 23
Thanks in advance (4 Replies)
Discussion started by: suryanarayana
4 Replies
7. Shell Programming and Scripting
I extract dates from the log file and need to calculate days between two dates. My dates are in yyyyMmmdd format. Example:
$d1=2011 Oct 21
$d2=2012 Feb 20
I need to calculate the number of days between $d2 and $d1. This is on Solaris.
Any ideas?
Thanks,
djanu (4 Replies)
Discussion started by: djanu
4 Replies
8. Web Development
Is this code good for this purpose?
<?php
$date1 = mktime(0,0,0,01,01,1991);
$date2 = mktime(0,0,0,03,22,2012);
$diff = $date2 - $date1;
$days = $diff / (60*60*24);
echo ($days . "<br />");
?> (3 Replies)
Discussion started by: kovacsakos
3 Replies
9. Shell Programming and Scripting
shell script to calculate difference between 2 dates (3 Replies)
Discussion started by: gredpurushottam
3 Replies
10. Shell Programming and Scripting
Gents.
Please can u help.
I would like to calculate the days between two dates.
Example file1 ( previous date)
file1 - Input file
9/29/2010 10195
9/29/2010 1057
2/2/2016 10
2/2/2016 10169
2/2/2016 1057
2/3/2016 10005
2/3/2016 10014
In file2 I add the actual date using this code.... (9 Replies)
Discussion started by: jiam912
9 Replies
LEARN ABOUT FREEBSD
service
SERVICE(8) BSD System Manager's Manual SERVICE(8)
NAME
service -- control (start/stop/etc.) or list system services
SYNOPSIS
service -e
service -R
service [-v] -l | -r
service [-v] <rc.d script> start|stop|etc.
DESCRIPTION
The service command is an easy interface to the rc.d system. Its primary purpose is to start and stop services provided by the rc.d scripts.
When used for this purpose it will set the same restricted environment that is in use at boot time (see below). It can also be used to list
the scripts using various criteria.
The options are as follows:
-e List services that are enabled. The list of scripts to check is compiled using rcorder(8) the same way that it is done in rc(8), then
that list of scripts is checked for an "rcvar" assignment. If present the script is checked to see if it is enabled.
-R Restart all enabled local services.
-l List all files in /etc/rc.d and the local startup directories. As described in rc.conf(5) this is usually /usr/local/etc/rc.d. All
files will be listed whether they are an actual rc.d script or not.
-r Generate the rcorder(8) as in -e above, but list all of the files, not just what is enabled.
-v Be slightly more verbose
ENVIRONMENT
When used to run rc.d scripts the service command sets HOME to / and PATH to /sbin:/bin:/usr/sbin:/usr/bin which is how they are set in
/etc/rc at boot time.
EXIT STATUS
The service utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
The following are examples of typical usage of the service command:
service named status
service -rv
The following programmable completion entry can be use in bash(1) for the names of the rc.d scripts:
_service () {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) )
return 0
}
complete -F _service service
SEE ALSO
bash(1) (ports/shells/bash), rc.conf(5), rc(8), rcorder(8)
HISTORY
The service utility first appeared in FreeBSD 7.3.
AUTHORS
This manual page was written by Douglas Barton <dougb@FreeBSD.org>.
BSD
December 11, 2012 BSD