B
B
Bur Ov2016-08-07 17:31:33
C++ / C#
Bur Ov, 2016-08-07 17:31:33

How to implement automatic termination of a process that is heavily CPU intensive?

I have several php scripts that need to be pulled every minute, but it happens that the script does not have time to execute, but cron pulls it again, apparently because of this there was such a trouble: I
went to pu, and there
mIX4Ow.png
I went to htop, there 3 processes are already running 7 hours and load the 4-core processor under 100%, while the RAM is occupied by 1GB out of 7. I killed these processes and the load dropped to 13%.
Is it possible to make it so that if some script generates a load of more than 40-50% on the processor, then it would automatically terminate?

ps: I understand that I described the question at random, but suddenly someone will understand) Thanks in advance!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Konstantin Malyarov, 2016-04-08
@Konstantin18ko

Google translator translated. Thanks to all.

A
abcd0x00, 2016-04-08
@abcd0x00

Set yourself a normal environment with a normal compiler. VS is simply trying to tie the user to itself, imposing its "safe" functions that are only in it.

M
Maxim Yakupov, 2016-04-08
@DeeplessHole

All the same, I think that the correct answer should sound :). The Microsoft plus compiler compiles under .Net, i.e. to bytecode for a virtual machine (CLR) with a garbage collector. Naturally, direct memory manipulations from the program become undesirable. Therefore, if you want to learn real pluses (with pointers), you should use another compiler, such as MinGW (Windows), GCC (Linux), Clang (OS X).

Павел Тузов, 2016-08-07
@burov0798

В идеале должен быть запущен только один инстанс?
Если да, то может стоит задуматься о том, чтобы проверять на выполнение предыдущего, прежде чем запускать новый.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question