home Mail List
Info
Info
Meetings
Goals
Upcoming
Projects
FAQ
Security
Links

[Date Prev][Date Next] [Chronological] [Thread] [Top]

[NMLUG] Random Questions #25



On Friday 23 April 2004 7:03 pm, Sarang wrote:
> Pretend I have a clever opening line here,
>
> % How can I test a command before putting it in my crontab file? [1]

> [1] Cron runs w/ a different path/shell/permissions/etc than my
> regular environment, so what works at my shell prompt may not work in
> cron. Obvious workarounds I dislike: 1) running the command every
> minute in cron (can be slow if you make a lot of mistakes, may have
> to wait up to a minute for each error message), 2) using a Perl
> script (Perl scripts usually work the same in cron and on the command
> line, but using Perl for simple tasks is inelegant).

For scripts that go in cron, it's good practice to always explicitly set 
the PATH and any other environment variables you depend on. If you want 
to test a script, say "cronscript.sh", you might run it like:

$ env --unset=PATH cronscript.sh

(or simpler if you use a bash-like shell):

$ PATH= cronscript.sh

Remember, you can declare a PATH in your crontab if you want it to be 
global for all scripts.

cronscript.sh should look something like:
#!/bin/sh
PATH=...whatever...

So that you explicitly know what path you are using. This is good 
security practice as well.

> % How can I get "rsync -a -e ssh root@remote:/dev/hda1 file.ufs" to
> work? (ie, rsync a remote EXT2FS filesystem to a local file) [2]

> [2] Rsync complains /dev/hda1's not a "regular file". True, but does
> it matter? Can't I tell rsync to just pretend it is? (I assume block
> files that are really hard drives can be treated as regular files,
> no?). I realize I could simply rsync the mount point for the device
> w/ the -X (--one-file-system) option, but that's inelegant since
> rsync would handle each file on the device separately. I could also
> tar/dd /dev/hda1 on the remote machine and then rsync the result, but
> that requires a lot more room on the remote system. The --devices
> option looks almost right, but I want the local result to be a true
> file (like the result of mke2fs), not a device.

It's not the reason rsync is complaining[1], but even if it tried to 
treat it like a regular file /dev/hda1 is a block device, not a 
character device, so it might not work like you'd expect.

If you want to get the effect of making an image of a remote device, 
it's a piece of cake. You can run something like this (network 
transparency and pipes to the rescue), for example. =)
 
ssh root@remote dd if=/dev/hda1 | dd of=file.ufs

[1] If you use the -D option, rsync will transfer "devices" but it only 
transfers the device information, not the contents. It's complaining 
because you pointed at a device but didn't use -D.

> % My keyboard almost freezes when rsync runs, how to fix? [3]

> [3] I run rsync from cron hourly (in a more normal way than in my
> previous question <G>). It works fine, but my keyboard almost freezes
> while rsync is running, EVEN IF I nice rsync to very low priority.
> "top" shows rsync always takes up LOTS of CPU time, even when niced
> way down. Any way to fix this? I tried upping the priority of
> ksoftirqd_CPU0 (which
> process/receives keyboard events???) but that didn't help either. A
> silly workaround is to UP the priority of rsync, so it runs faster
> (but slows down the keyboard even more during the shorter time it's
> running).

This might not be the problem, but it sounds a lot like DMA is off on 
your hard drive. Install hdparm and check with:

hdparm -d /dev/hda

That will report if it's on or off. As for actually turning it on, you 
should probably read up on your IDE chipset and drive before you do 
that, as for a small fraction of drives/chipsets, it's dangerous to 
enable DMA.

> % Is there an emacs function to insert current date/time? [4]

> [4] The temptingly-named "time-stamp" command does NOT do this,
> sadly. Could I define/defun a function that spews the output of
> "date" (or presumably any Unix command) to the current buffer? It's
> easy to write an emacs function that RUNS the command "date" (or
> whatever), but I can't figure out how to "redirect" the output to the
> current emacs buffer.

(insert-string (shell-command-to-string "date"))

-- 
Wesley J. Landaker <wjl@icecavern.net>
OpenPGP FP: 4135 2A3B 4726 ACC5 9094  0097 F0A9 8A4C 4CD6 E3D2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://lists.b9.com/pipermail/nmlug/attachments/20040424/adeb2aae/attachment.pgp



Please send sugestions and comments to webmaster@nmlug.org.
Valid XHTML 1.1! Valid CSS! Powered by Debian Powered by Apache