ps utility does not show the year a process was started - unix

I am doing some work on a fairly old system and need to know when a couple of processes started. When I use "ps -ef" one says October 18 and the other March 23. We haven't got to October 18 this year so I'm not sure if this is October 18 last year or the previous year. The uptime command is showing 2419 days (6.6 years!) so it's possible the Oct 18 is from earlier than 2012. This is a HP-UX system. I have done a bit of googling and none of the answers I came across worked, eg ps -o, looking in the /proc dir.
cfgmgr 9947 9943 3 Mar 23 ? 6831:32 /home/cfgmgr/bin/snmpagt
root 24338 1 0 Oct 18 ? 2628:13 /usr/sbin/snmpdm -tcplocal

PS can only show the date because as per PS documentation at MAN page
'Only the year will be displayed if the process was not started the same year ps was invoked, or "mmmdd" if it was not started the same day, or "HH:MM" otherwise.'

Related

Cron job run at the wrong time in AIX 7.1

I had configured my cronjob to run in every first Monday of the month 8:40am as below
40 08 1-7 * 1 /fs/test/testtime.sh
But it not only run on Monday, it also run on today which is Tuesday.
Is there anything i miss out?
From the man page for crontab (my emphasis):
Note: The day of a command's execution can be specified by two fields - day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time.
For example, 30 4 1,15 * 5 would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
So, in your case, the job runs on every one of the first seven days in each month, plus every Monday.
You can do what you wish by adding an AND condition in the command rather than relying on an OR condition in the time specification, something like:
40 08 1-7 * * test $(date +\%u) -eq 1 && /fs/test/testtime.sh
This will run the actual cron job on all those days (first seven days in each month) but the payload (the script) will only run if the day is Monday.

Why Oracle DataDump creates N-1 files if parallelism is set to N?

What am I doing wrong?
I set PARALLEL=4 but number of files created are 3.
time expdp data DIRECTORY=EXT_DIR TABLES=DATA.ST_EURKMORDER:P108 LOGFILE=log.txt CONTENT=DATA_ONLY COMPRESSION=DATA_ONLY DUMPFILE=DATA.ST_EURKMORDER_P108_compr_%U_out_of_4.dmp PARALLEL=4
Expected 4 files, but got 3:
ls -alh /data/DATA.ST_EURKMORDER_P108_compr_1*
-rw-r----- 1 oracle oinstall 170M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_01_out_of_4.dmp
-rw-r----- 1 oracle oinstall 159M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_02_out_of_4.dmp
-rw-r----- 1 oracle oinstall 151M Apr 11 13:38 /data/DATA.ST_EURKMORDER_P108_compr_03_out_of_4.dmp
According to the documentation, the PARALLEL setting (emphasis added):
Specifies the maximum number of processes of active execution operating on behalf of the export job.
It also shows an example similar to yours with PARALLEL set to four, which it says results in an export
... in which up to four files could be created ...
There are various other examples that refer to 'up to' as well. So, this is the expected behaviour. It could create four files, it could create fewer than that.

How to use ubuntu command line to find a holiday?

How to use ubuntu command to find the date of Mother's Day (Second Sunday of May) in 2017?
Since -v doesn't work on ubuntu, it works on Mac.
Lets say its usually the second sunday of may :
fhenri#machine:~$ date -v1d -v5m -v+1y -v+2w -v-sun
Dim 14 mai 2017 22:56:28 CEST
you should look at man date to get more examples and to find out if you need another particular sunday or fix day
I was running on my macos (freeBSD based) and did not realized date was not uniform across *nix system.
on ubuntu, it revealed a bit more difficult but here how I would go
vagrant#ubuntu:~$ firstofmay=$(date -d '05/01/2017')
vagrant#ubuntu:~$ firstsunday=$(date -d "$firstofmay" '+%Y-%m')-$(( 8 - $(date -d "$firstofmay" '+%u') ))
vagrant#ubuntu:~$ secondsunday=$(date -d "$firstsunday + 1 week" '+%Y-%m-%d')
vagrant#ubuntu:~$ echo $secondsunday
2017-05-14
first I initialize the 1st of may as my base date
then I get a format of the first sunday from this month: day are 7 based and $(date -d "$firstofmonth" '+%u') will be the day number of the first of may (i.e.: monday is 1); this gives a format such as YYYY-MM-dd
adding 1 week to this date I have previously gives the correct date - adjust the formatting if you want it different

A cron job that will never execute

Is there any way to create a cron expression for not running the job at all?
I though of using this expression :
0 0 0 1 1 ? 3099
...which will practically do the job as it will run on year 3099, but is there a cleaner way to do it?
If you're still looking for something robust even in the far future, try https://stackoverflow.com/a/13938099/1601531, where I suggest the use of February 31st in crontab entries which are never intended to execute.
0 0 5 31 2 ?
I needed a valid cron schedule (? syntax not working in my system) which resolves real dates, but to be effectively "never". My current best solution was to pick the most recent leap year and see what day Feb 29th fell on. Feb 29 2016 was a Monday, so the next Monday Feb 29 is currently furthest away.
0 0 29 2 1 yields the next 5 triggers as:
02/29/2044 00:00:00Z
02/29/2072 00:00:00Z
02/29/2112 00:00:00Z
02/29/2140 00:00:00Z
02/29/2168 00:00:00Z
Not perfect but it'll do.
Pick a date in the past.
That'll never happen again. Unless it's groundhog day. Just don't pick groundhog day.
I created a duplicate (click here to see) for your question, and agree with your initial proposal. After testing, it appears Quartz will never execute a cron expression with a year above 2300.
Opening your crontab file and deleting the entry would be the adequate way. Or you might as well simlink the executable that's called by the cronjob to an empty shell script.
Tell us more about your setup, then we'll see ...
Comment it out — put # sign in front of it. Very useful, especially if you're afraid you'll forget about your changes by the year 3099.
Another possibility is to make it execute dummy command, like true rm -rf /.

Schedule Task : 6 months from now

I'm tryin' to find a way (from a batch file) that I can use to create a scheduled task that will execute 6 months from now. I've looked all over the net, and I'll I've come across is AT and SCHTASKS that will schedule the task monthly ..
I'm looking for a solution that will execute this task every 6 months.
I know this will require some time/date manipulation .. finding the month (number of month) and then adding 6 to it; once it passes '12' it goes back to 1 etc .. Then lining those numbers up with the months name, and using SCHTASKS or AT to schedule the task.
I know how to use SCHTASKS to schedule a task from a batch file; I just need the code to find the month, add 6 to it, grab the months name in 6 months time, and put that into a variable so I can parse it into the SCHTASKS.
I hope this all makes sense.
My english is not so great.
TIA,
Greg
Thanks to everyone who replied, and offered suggestions. I slept on it, woke up with the flu, and had a brainwave. Funny how things work out. I know this is overkill, and someone will come up with a better suggestion, but here goes anyway ..
REM Grab month number and put into variable
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
REM Six months from now
set /a addmm=%mm% + 6
if %addmm% gtr 6 (set /a sixmonths=%addmm% - 12)
REM Determine month name
if %sixmonths%==1 (set monthname=JAN)
if %sixmonths%==2 (set monthname=FEB)
if %sixmonths%==3 (set monthname=MAR)
if %sixmonths%==4 (set monthname=APR)
if %sixmonths%==5 (set monthname=MAY)
if %sixmonths%==6 (set monthname=JUN)
if %sixmonths%==7 (set monthname=JUL)
if %sixmonths%==8 (set monthname=AUG)
if %sixmonths%==9 (set monthname=SEP)
if %sixmonths%==10 (set monthname=OCT)
if %sixmonths%==11 (set monthname=NOV)
if %sixmonths%==12 (set monthname=DEC)
REM Schedule Task
schtasks /create /TN TuneUpReminder /RU system /TR TuneUpReminder.bat /SC MONTHLY /M %monthname%
Why not use the Windows Scheduler?
Most of the information you need is included in this article: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true
You can use the monthly setting, with a value of 6 surely?
Here's a crazy idea: in case you want this script on a server (which isn't rebooted), you could write a batch file which waits for six months and then executes the given program. To wait for a specific number of seconds you could abuse the 'ping' command, like this:
ping -n %SECS% localhost > NUL
This command will effectively pause for %SECS% seconds and then return. To wait for six months, simply wait for something like (365 / 2) * 24 * 60 * 60 seconds.
Here's a little batch file which implements this idea:
#echo off
set CMD=echo Half a year elapsed
set /a SECS_IN_HALF_A_YEAR=365 / 2 * 24 * 60 * 60
loop_start:
ping -n %SECS_IN_HALF_A_YEAR% localhost > NUL
%CMD%
goto loop_start
I'm not saying it's pretty, but I thought it's a funky idea. Maybe some food for thought. :-)
you can download coreutils for windows . Then use date command like this
C:\test>gnu_date "+%Y%m%d" -d "6 months"
20110404
(it is renamed to gnu_date.exe )
I have not played with schtasks, but depending on what format of date it uses, you can change the parameters to suit schtasks
C:\test>gnu_date "+%Y-%m-%d" -d "6 months"
2011-04-04
If you need time as well
C:\test>gnu_date "+%Y-%m-%d-%H:%M:%S" -d "6 months"
2011-04-04-18:12:35
Use a for loop to save the date to a variable as desired. then pass it to schtasks for scheduling
Since Greg's answer made me cry inside, here is some array like syntax:
for /F "tokens=%sixmonths%" %%A IN ("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC") DO set monthname=%%A
And since there’s always more than one way to skin a bat[ch]?
set /a sixmonths=%sixmonths% * 4
set months=666 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
setlocal ENABLEDELAYEDEXPANSION
set monthname=!months:~%sixmonths%,3!
REM Optional: setlocal DISABLEDELAYEDEXPANSION

Resources