hp-ux

In a unix shell, how to get yesterday's date into a variable?

有些话、适合烂在心里 提交于 2019-11-26 22:43:01
问题 I've got a shell script which does the following to store the current day's date in a variable 'dt': date "+%a %d/%m/%Y" | read dt echo ${dt} How would i go about getting yesterdays date into a variable? Basically what i'm trying to achieve is to use grep to pull all of yesterday's lines from a log file, since each line in the log contains the date in "Mon 01/02/2010" format. Thanks a lot 回答1: If you have Perl available (and your date doesn't have nice features like yesterday ), you can use:

Cross-platform way to get PIDs by process name in python

萝らか妹 提交于 2019-11-26 19:01:48
问题 Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython ? I want something like pidof but in python. (I don't have pidof anyway.) I can't parse /proc because it might be unavailable (on HP-UX). I do not want to run os.popen('ps') and parse the output because I think it is ugly (field sequence may be different in different OS). Target platforms are Solaris, HP-UX, and maybe others. 回答1: You can use

How to get the command line args passed to a running process on unix/linux systems?

点点圈 提交于 2019-11-26 11:45:31
问题 On SunOS there is pargs command that prints the command line arguments passed to the running process. Is there is any similar command on other Unix environments? 回答1: There are several options: ps -fp <pid> cat /proc/<pid>/cmdline | sed -e "s/\x00/ /g"; echo There is more info in /proc/<pid> on Linux, just have a look. On other Unixes things might be different. The ps command will work everywhere, the /proc stuff is OS specific. For example on AIX there is no cmdline in /proc . 回答2: This will