How could I configure a process so it does not run continouesly

Hi

I have Samsug CLP 315 laser printer. To my delight Samsung provides software to monitor the fill level of the cartriges.

I found that is done by a process which continuesly uses cpu power. Very little…but anyway. A constant check is not necessary.

How and where could I configure this process, so it would run lets say very hour of so?

thanks Otto

Hi there,

i do not know much about this special printer, but maybe there is a way to check it via SNMP (as many printers can do today), maybe you could take a look as nagios (Nagios - The Industry Standard in IT Infrastructure Monitoring) would do it and borrow :slight_smile: a script from the exchange page.
So you could run this little script per cronjob cron - Wikipedia, the free encyclopedia and put the output into an email which is send to you (or every other person who wants to know)

just an idea

Thanks johest

I will look into your suggestions and post the results

cheers

otto oz wrote:

>
> Hi
>
> I have Samsug CLP 315 laser printer. To my delight Samsung provides
> software to monitor the fill level of the cartriges.
>
> I found that is done by a process which continuesly uses cpu power.
> Very little…but anyway. A constant check is not necessary.
>
> How and where could I configure this process, so it would run lets say
> very hour of so?

You put it in the crontab. You have essentially three choices:

  1. the system crontab /etc/crontab
  2. a separate file in /etc/cron.d
  3. your personal crontab (if you can the process as a user, you
    run “crontab -e” to edit your personal crontab.)


Per Jessen, Zürich (14.9°C)
http://en.opensuse.org/User:pjessen

Dear pjessen,

His problem is how to stop the process after say one check. Of course then he could start that prcocess every hour or so via cron. But if he does as you suggests, he will have 24 of those processes running together after a day.

Dear otto_oz,
As you can see from the above it is easy to start it every hour (or whatever). But how can you tell the process to stop after doing a check and not continue doing so? For this you must have the documentation of the program. Maybe there is an option to tell it to do just one check (or the like). Do you have any doc going with the program?

Hi hcvv,

thats why i told him to take a look at the nagios processes, cause they terminate.
And a check via snmp would timeout every time if the snmpget or perl (or python or whatever) timeout is reached.

Sometimes i feel ignored.

You are not ignored by me for that matter. I only thought it worthwhile to ass to pjessen’s adivice because it is not complete.

When you solutions works (of which you are not sure, not being intimate to that particular type of printer) it indeed contains the full solution.

hcvv wrote:

>
> Dear pjessen,
>
> His problem is how to stop the process after say one check.

Henk, you clearly have a better crystalball than me :-). It certainly
wasn’t obvious to me that Otto wanted to stop anything.

> Dear otto_oz,
> As you can see from the above it is easy to start it every hour (or
> whatever). But how can you tell the process to stop after doing a
> check and not continue doing so?

Well, if the process is intended to monitor the printer continuously,
why not let it do its job? Starting and stopping it will likely
consume more (even if not measureably) resources than just leaving it
to run.
If you really want to start the process and then stop it after e.g. 10
seconds, it can be done with a simple script

(sleep 10; kill $(pidof <process>)&
exec process

(not tested)


Per Jessen, Zürich (16.3°C)
http://en.opensuse.org/User:pjessen

johest wrote:

>
> Hi hcvv,
>
> thats why i told him to take a look at the nagios processes, cause
> they terminate.
> And a check via snmp would timeout every time if the snmpget or perl
> (or python or whatever) timeout is reached.
>
> Sometimes i feel ignored.

It was a pretty big gun you were proposing, especially for someone who
thought it best to stop&start a process that is meant to be left
running.


Per Jessen, Zürich (17.0°C)
http://en.opensuse.org/User:pjessen

In principle I appreciate the idea to let it run. The are much more daemons running and that is how the system works. And it most probably isn’t worth spending any resources to change this.

But the ideas brought forward are allways an inspiration to try out different things or at least to try to find information about them. And imho there are three things brought forward where Otto can try to find more information and thus kowledge about:

  1. the documentation of his deamon;
  2. what is cron and how does it work;
  3. a possible complete different way to do the check as suggested by johest.

BTW no crystall ball nor equivalents used, the OP said:

I found that is done by a process which continuesly uses cpu power. Very little…but anyway. A constant check is not necessary.

which means imho that he wants to stop it and then starts it again later. But I admit that “stopping after one check” was a guess of mine.

On 2010-07-29 12:45, Per Jessen wrote:

> hcvv wrote:
> Well, if the process is intended to monitor the printer continuously,
> why not let it do its job? Starting and stopping it will likely
> consume more (even if not measureably) resources than just leaving it
> to run.

Well, not if it doesn’t run again till next day, or hours later. The memory can be put to other uses.

> If you really want to start the process and then stop it after e.g. 10
> seconds, it can be done with a simple script
>
> (sleep 10; kill $(pidof <process>)&
> exec process

I would start it in cron (hourly or daily), wait a few minutes, and then kill it - provided the
application does not display anything.

Better read its documentation. Is it a daemon? An applet?

If it is an applet, then the OP needs a script in the autostart folder of his desktop (start; sleep;
kill; sleep longer; repeat)


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))

Carlos E. R. wrote:

> On 2010-07-29 12:45, Per Jessen wrote:
>
>> hcvv wrote:
>> Well, if the process is intended to monitor the printer continuously,
>> why not let it do its job? Starting and stopping it will likely
>> consume more (even if not measureably) resources than just leaving it
>> to run.
>
> Well, not if it doesn’t run again till next day, or hours later. The
> memory can be put to other uses.

If necessary, it will be. A sleeping process is swapped out quite
quickly.

>> If you really want to start the process and then stop it after e.g.
>> 10 seconds, it can be done with a simple script
>>
>> (sleep 10; kill $(pidof <process>)&
>> exec process
>
> I would start it in cron (hourly or daily), wait a few minutes, and
> then kill it - provided the application does not display anything.

There are a many ways to skin a cat, but given that the process is meant
to run as a daemon, anything else is just kludgy.


Per Jessen, Zürich (18.1°C)
http://en.opensuse.org/User:pjessen

Hi there
Thanks for the tech hints…done it. Believe or not the most problems I had to figure out the correct syntax for crontab. So what I did…yes…I made a backup of the org crontab.
next script as pjessen suggested

#SMFPD run process 10 seconds
/usr/sbin/smfpd
sleep 10
kill $(pidof smfpd)

included this into crontab
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root

check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly

-*/15 * * * * root test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1

#Samsung CLP315 start script every hour

  • -/1 * * * root /etc/acronsmfpd
    #Samsung CLP315 start script every minute
    #-
    /1 * * * * root /etc/acronsmfpd

as you can see I tested it for “every minute” first

By the way to edit crontab there is a nice editor called “emacs”
Was a bit fiddley but worthwhile since the process used around 8% of CPU

Thanks Otto

There is the monitoring application dependency where one has to startup the process on demand. Solved this by writing a script.

Hi there,

there is a more nice editor called vim (vi) to do so.
But i think “crontab -e” should open the same file with the vi also.

Hi johest

I’ll try vim text time.
The script for the desktop on demand was a bit of a @#$%. At least for me since I have done only “very minor” scripts. Here is the script

#SMFPD activate smartpanel and kill when app is not used
/usr/sbin/smfpd
/opt/Samsung/SmartPanel/bin/smartpanel
#[Desktop Entry]
Encoding=UTF-8
Name=Samsung Smart Panel
Exec=/opt/Samsung/SmartPanel/bin/smartpanel
Type=Application
Icon=/opt/Samsung/SmartPanel/share/icons/sp_default.png
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
Categories=Application;SystemSetup;X-Samsung-Smartpanel;
kill $(pidof smartpanel)
kill $(pidof smfpd)

It stays alive in the panel until you “quit”

cheers

…just to add…no magic…just copied the relevant stuff out of the desktop icon…so there are maybe some redundant lines…don’t care it works.

One should NEVER use an editor, but always use* crontab -e* when editing one’s crontab file!

hcvv wrote:

>
> johest;2198601 Wrote:
>> Hi there,
>>
>> there is a more nice editor called vim (vi) to do so.
>> But i think “crontab -e” should open the same file with the vi also.
>
> One should NEVER use an editor, but always use- crontab -e- when
> editing one’s crontab file!
>

Except if one is root, and wants to edit /etc/cron.d/something :slight_smile:


Per Jessen, Zürich (17.2°C)
http://en.opensuse.org/User:pjessen

On 2010-07-30 06:06, otto oz wrote:
>
> Hi there
> Thanks for the tech hints…done it. Believe or not the most problems
> I had to figure out the correct syntax for crontab. So what I
> did…yes…I made a backup of the org crontab.
> next script as pjessen suggested

You are editing /etc/crontab? Please, don’t, it can be replaced on updates. Better if you use root
or a user’s crontab, which is accessed via “crontab -e” while logged in (in a terminal) as that user.

> By the way to edit crontab there is a nice editor called “emacs”

There are several editors. If you want some fun, I suggest you google for “emacs vs vi” or the other
way round, you will find thousands if not millions of flame wars with everybody claiming one or the
other is the best editor in the world. :slight_smile:

However… if you intend to get serious with linux, learn at least the very basics about “vi”,
because in emergencies that is the only one available, and the only one guaranteed to be available
in any linux or unix system (I believe). At least, how to write, save, and exit. Not trivial, I
assure you, specially if you come from windows world (as I do).

(me, I strongly dislike both :-p )

Then, I sugest you try “joe” (with several incarnations to choose from) and “mcedit”, part of “mc”,
which I also recomend you try.

Now, “crontab -e” launches “vi” on the appropriate file; you can change this so that your choice of
editor (text mode) is used instead.

> Was a bit fiddley but worthwhile since the process used around 8% of
> CPU

That’s a lot.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Elessar))