unix

Changing syslog log path

独自空忆成欢 提交于 2021-01-27 23:30:43
问题 How do I change the log path of syslog daemon during runtime? My goal is to rotate log file every filesize or date, but I don't have logrotate in QNX/POSIX. Do I just do an edit and hope that the syslogd checks the .conf file everytime, or is there any other workaround? Thanks. Clarification: It has to be done in C or C++, not in script and console command line, for portabality issues. 回答1: Find the pid of syslogd. Let's say it's 123. Then, after you've finished your edit, on the command line

Java “package does not exist” error in UNIX

≯℡__Kan透↙ 提交于 2021-01-27 20:38:50
问题 My project directory structure is something like this: ProjectName/coursesRegistration/src/coursesRegistration/util When I do "import coursesRegistration.util.FileProcessor; " in Eclipse it works but when I try this on UNIX (using command line compilation) it gives me an error saying "error: package coursesRegistration.util does not exist". Maybe I am missing something very basic, does anyone know what may be the problem? 回答1: If you're trying to do command-line compilation, this is probably

Unix - Convert GMT time field to PST time

六眼飞鱼酱① 提交于 2021-01-27 19:05:27
问题 Sorry if this has been asked before. I have a text file that contain a field with GMT time on Unix. I want to convert that field to the PST time zone in the same format. source file test.txt 20200804T221806.214 GMT,2003060015,2003060018 20200804T232027.571 GMT,2005260045,2005260095 20200804T232027.572 GMT,2005260045,2005260095 20200805T000119.715 GMT,2005290022C,2005290042D 20200805T000119.715 GMT,2005290022C,2005290042D 20200801T000326.111 GMT,2005290028C,2005290050D 20200101T000326.111 GMT

Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?

自古美人都是妖i 提交于 2021-01-27 17:04:58
问题 I came across some code in C where we check the return value of wait and if it's not an error there's yet another check of WIFEXITED and WIFEXITSTATUS . Why isn't this redundant? As far as I understand wait returns -1 if an error occurred while WIFEXITED returns non-zero value if wait child terminated normally. So if there wasn't any error in this line if ( wait(&status) < 0 ) why would anything go wrong durng WIFEXITED check? This is the code: #include <stdio.h> #include <signal.h> #include

Node cluster workers memoryUsage

我是研究僧i 提交于 2021-01-27 17:01:56
问题 Does anyone know if there is a platform independent way to get memory usage of a worker? I would expect it would work like this: console.log('App process memoryUsage: ',process.memoryUsage()); cluster.on('online',function(worker){ // doesn't work! console.log('Workers memory usage: ',worker.process.memoryUsage()); }); But the workers process hasn't the method memoryUsage() . Is there a valid reason this isn't implemented ? The only idea to realize this is to work with unix top -pid 1234

Node cluster workers memoryUsage

寵の児 提交于 2021-01-27 17:01:53
问题 Does anyone know if there is a platform independent way to get memory usage of a worker? I would expect it would work like this: console.log('App process memoryUsage: ',process.memoryUsage()); cluster.on('online',function(worker){ // doesn't work! console.log('Workers memory usage: ',worker.process.memoryUsage()); }); But the workers process hasn't the method memoryUsage() . Is there a valid reason this isn't implemented ? The only idea to realize this is to work with unix top -pid 1234

Kernel: Dealing with deadlocks in unix

你说的曾经没有我的故事 提交于 2021-01-27 13:46:38
问题 A deadlock would occur if process 1 locks resource A and waits for resource B , while simultaneously (due to context switches at the "right" places) process 2 locks resource B and waits for access to resource A . How does Unix deal with such deadlocks? I read the following here . Many deadlocks can be prevented by simply requiring all processes that lock multiple resources to lock them in the same order (e.g., alphabetically by lock name) How can it change the order in which locks are

bash find using regex is not case sensitive

廉价感情. 提交于 2021-01-27 13:26:13
问题 I need to find files starting with three lowercase letters but for some reason I'm getting an undesired case-insensitive behavior. I'm using find with the -regex option but it finds even the files starting with capital. $ find . -regextype posix-egrep -regex '.*/[a-z]{3}\w+\.abc' ./TTTxxx.abc ./tttyyy.abc prints the same as: $ find . -regextype posix-egrep -regex '.*/[A-Z]{3}\w+\.abc' ./TTTxxx.abc ./tttyyy.abc If instead of using a range of characters I use a single character, works as

List all the mondays of this month

折月煮酒 提交于 2021-01-27 13:20:25
问题 I'm pretty new to bash and all the terminal in general - I've been messing around with cal and the date scripts wondering if there is anyway to list all the dates of monday of the current month . My thought process is going thru the cal command, listing out the dates and maybe cutting a column from that input. Is that possible ? 回答1: You can do it with date command. Print 10 mondays since month ago: for x in $(seq 0 9) do date -d "$x monday 5 week ago" done And grep only current month. Full

How to delete the lines starting from the 1st line till line before encountering the pattern '[ERROR] -17-12-2015' using sed?

▼魔方 西西 提交于 2021-01-27 11:43:29
问题 I need to delete lines from the 1st line till line before encountering the pattern '[ERROR] -17-12-2015' Currently I am trying the below command but unfortunately it does not find the pattern itself: sed '1,/[ERROR] -17-12-2015/d' errLog What is wrong here? Secondly, the above script will also delete the line containing pattern '[ERROR] -17-12-2015' , is it possible to delete only the lines from the first line to the line before encountering this pattern ? The Sample input is: [ERROR] -09-11