Is it possible to run a cron-job in 1.0.4?

Using applications, configuring, problems
Post Reply
Message
Author
Staffan
Posts: 12
Joined: Wed 14 Sep 2005, 07:41
Location: Sweden

Is it possible to run a cron-job in 1.0.4?

#1 Post by Staffan »

Hello,

is it possible to run a cron-job in PuppyLinux 1.0.4 or do I have to install something for this to be possible?

Regards,

Staffan

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

You could try a small shellscript.

I saved it in /root/notcron

notcron.sh

Code: Select all

#!/bin/sh

mytime=`date +%k%M`
checktime=`head -n 1 /root/notcron/mytask.txt | sed "s/#.*$//"`
todo=`head -n 1 /root/notcron/mytask.txt | sed "s/^[^#]*#//"`

echo current time is: $mytime
echo next task $todo at:  $checktime

if [ "$mytime" = "$checktime" ]; then
  $todo &
fi
sleep 60
$0
You also need a file that has the instruction what to do:
mytask.txt

Code: Select all

1749#leafpad
-----
First make it executable:
chmod 755 /root/notcron/notcron.sh

Start it before starting X in one of the startup-scripts:
/root/notcron/notcron.sh &

The & runs it in background.

Limitations:
it just runs 1 command, for more it had to be enhanced.
Or you make copies (notcron02.sh, mytask02.txt)

Greets, Mark

Staffan
Posts: 12
Joined: Wed 14 Sep 2005, 07:41
Location: Sweden

#3 Post by Staffan »

Many thanks!

This is probably precisely what I need. Do you by any chance know if there is a way to see how long it was since the keyboard (or mouse) was used? I would need it to see if I should suspend the computer or not.

Regards,
Staffan

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#4 Post by MU »

Yes.

At least for the mouse:
http://www.murga.org/%7Epuppy/viewtopic.php?t=2814

To be enhanced...

Greets, Mark

Staffan
Posts: 12
Joined: Wed 14 Sep 2005, 07:41
Location: Sweden

#5 Post by Staffan »

thanks for the link, but where is the code? Is it in the .pup-file? If so, how do I read it? You got it right with that I want to use a screensaver-like application to shut down the computer once it has been left idle for a while.

Regards,
Staffan

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#6 Post by MU »

Install the pup.

Then replace /usr/local/PuppyBasicScreensaver02/resource/sc.sh with your own shellscript.

If you do it, you should not run the "choose module" in the grafical setup, as it overwrites sc.sh with the shellscripts that are part of my screensaver.


This solution uses a patched version of rsaver, a small screensaver written in C.
I included the source in the Dotpup for C-coders (but it is not needed to look at it).
My patch is only to run sc.sh instead of starting the inbuilt grafics of the original rsaver.

If things remain unclear, please ask again.

Mark

Post Reply