Active Topics

 



Notices


Reply
Thread Tools
Posts: 145 | Thanked: 32 times | Joined on Dec 2007
#1
anyone know where to get a version of slocate that
will run on the n810 (os2008)? TIA,
 

The Following User Says Thank You to albright For This Useful Post:
free's Avatar
Posts: 739 | Thanked: 159 times | Joined on Sep 2007 @ Germany - Munich
#2
I thought about porting it (slocate is very usefull yes) but slocate database needs to be frequently updated, through cron. There is no cron tasks by default (but cron system is there). I wonder if there is a reason (performance or anything related).. ?
 
Benson's Avatar
Posts: 4,930 | Thanked: 2,272 times | Joined on Oct 2007
#3
Originally Posted by free View Post
I thought about porting it (slocate is very usefull yes) but slocate database needs to be frequently updated, through cron. There is no cron tasks by default (but cron system is there). I wonder if there is a reason (performance or anything related).. ?
Well, battery life will suffer... it's just like metalayer-crawler. But it should work, even without cron. Either start at every boot, or let the user manually run it when they want. slocate can run without cron.

Oh wait, I'm thinking like a slackware , or worse, a UNIX man.
This is debian, so slocate package must depend on cron, because you typically want to run it that way, and you can't have a package that requires the sysadmin to, you know, admin the sys...

I'd gladly take such a thing, if you could get it with no cron dep. It'd be useful to me if I updated the db once a month, because I'm usually hunting some system file, which don't change much.
Though it occurs to me, the tablets need something like anacron, only power-supply aware. If the tablet's charging (and the battery's over, say, 30% full), and it's been over <24hrs | 1 week | 1 month> since the task was last run, then re-run it... Be a good project for me, when I get time
 
Posts: 145 | Thanked: 32 times | Joined on Dec 2007
#4
why not just run a script something like this:

while true
do
sleep 24 hrs
if charging
then
updatedb
done

I usually leave my n810 plugged in over night,
so if I start this script at the right time ....

is there a problem with faking cron like this?

anyway, I'd be happy to run slocate manually so
I hope it gets ported (there is a version for the
770 it seems but it won't install on the n810
see: http://lucidvisions.com/#nes)
 
rcull's Avatar
Posts: 299 | Thanked: 168 times | Joined on Jun 2006 @ Wales UK
#5
There is a simpler way.

create two scripts in /usr/bin called updatedb and locate

updatedb
Code:
find / -print > /medi/mmc2/locate.db
locate
Code:
grep "$1" /media/mmc2/locatedb | more
then use
Code:
crontab -e
to add the following line in roots crontab

Code:
0 4 * * * /usr/bin/updatedb
then to run just use
Code:
locate leafpad
Rick
 

The Following 2 Users Say Thank You to rcull For This Useful Post:
Benson's Avatar
Posts: 4,930 | Thanked: 2,272 times | Joined on Oct 2007
#6
Albright, that'd work for a while, but eventually the execution time of the rebuild makes drift out of sync, and then you could go weeks without an update.

A better thing is to check once an hour or so, so (assuming your plug-in at night is precisely periodic), it'd drift an hour, then get caught on the "previous" iteration. But then you do have to check when it was last run so you aren't running it 6 times a night. I assume that's what you were trying to dodge.

Try:
Code:
#!/bin/sh
while :; do
  if [ `date +%H` == 00 ] && sleep 10 && [ "x`battery-status|grep Charging`" != x ]; then
    play-sound /usr/share/sounds/ui-wake_up_tune.wav
  fi
  sleep 3590
done
The naive approach (sleep 3600) would skip once in a great while, because even when nothing happens, the condition evaluation and loop overhead cause drift. Every once in a while, it'll be 23:59:59.99 one iteration, and 01:00:00.01 the next, so you'll miss one. We avoid that by fudging the time below an hour, but delaying extra when we do hit so we don't hit it twice in the same hour. You could shift the sleep 10 into the then clause, but then it would sometimes check at 00:00:01, see the battery's not charging, and then check again at 00:59:51 and (if it was plugged in then) then run it. Your choice which behavior is better.



Rick, your
Originally Posted by rcull View Post
locate
Code:
grep "$1" /media/mmc2/locatedb | more
would work, but if you intend to call your script locate, it'd be good to behave a little more like locate. Leave out the '| more', so it could be used in scripts/pipelines.
 

The Following User Says Thank You to Benson For This Useful Post:
rcull's Avatar
Posts: 299 | Thanked: 168 times | Joined on Jun 2006 @ Wales UK
#7
Benson
It works and has been working for over a year. I use this regularly and find the '|more' extremely usefull. You can of course 'locate libcurl |more' its just more typing.
Rick
 
Benson's Avatar
Posts: 4,930 | Thanked: 2,272 times | Joined on Oct 2007
#8
Originally Posted by rcull View Post
Benson
It works and has been working for over a year. I use this regularly and find the '|more' extremely usefull. You can of course 'locate libcurl |more' its just more typing.
Rick
Sure it works, but you're replacing a standard command with a broken version. Replacing commands with stripped-down versions, supporting only a subset of functionality, but operating properly within that subset, is quite acceptable. Replacing commands with broken versions to save typing is quite ******ed. Have you ever heard of the alias built-in? Use that to save typing, and don't cram extra functionality into programs to break them!

(In case you're as familiar with tools as with UNIX, you should know that large screwdrivers (14" and up, often smaller ones too) generally have a hexagonal section below the handle, so a wrench may be used when more torque is required to bust a stubborn screw loose.)
It's like saying "Sometimes I need to use a wrench on my screwdriver, so I'll make a screwdriver with a big @#$%ing handle sticking out the side so I can use it that way!"
 
Posts: 145 | Thanked: 32 times | Joined on Dec 2007
#9
rcull's suggestion is not too bad, but I need more
help with the "crontab -e" command on my
n810
 
linuxrebel's Avatar
Posts: 182 | Thanked: 46 times | Joined on Jan 2007 @ Silly-Con Valley
#10
Not to belittle the merits of meaty tools I for one would love slocate. As for cron, why not set it to oncce a week.
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:45.