Source code - compiling busybox

Just wondering where I find the source code to the busybox utility. I need usleep to work. Odd it was left out. Fpr what it's worth here's some code I wrote in bash for subsecond timing and other odd timings that need some precision. If someone gets usleep to work you can use and distribute this code.

! /bin/sh

chkconfig: 2345 91 61

description: This program is used to run all programs in a directory in parallel every X times per minute. \

Think of this program as cron with microseconds resolution.

Microsecond Cron

Usage: cron-ms start

Copyright 2014 by Marc Perkel - marc@perkel.com

docs at http://wiki.junkemailfilter.com/index.php/How_to_run_a_Linux_script_every_few_seconds_under_cron

Free to use with attribution

The scheduling is done by creating directories with the number of

executions per minute as part of the directory name.

Examples:

/etc/cron-ms/7 # Executes everything in that directory 7 times a minute

/etc/cron-ms/30 # Executes everything in that directory 30 times a minute

/etc/cron-ms/600 # Executes everything in that directory 10 times a second

/etc/cron-ms/2400 # Executes everything in that directory 40 times a second

case "$1" in

start|restart|reload) $0 stop mkdir -p /var/run/cron-ms

Here I'm adding some extra directories to the $PATH.

PATH=/usr/local/sbin:/usr/local/bin:$PATH export PATH

for dir in /etc/cron-ms/* ; do $0 ${dir##*/} & done

exit ;;

stop) rm -Rf /var/run/cron-ms exit ;;

esac

Loops per minute is passed on the command line as $1

microseconds=$((60000000/$1))

After a restart the PIDs will be different allowing old processes to terminate

Touching /var/run/cron-ms is a heartbeat signal that can be used with monit to verify it's alive

touch /var/run/cron-ms /var/run/cron-ms/$$

Sleeps until a specific part of a minute with microsecond resolution. 60000000 is full minute

usleep $(( $microseconds - $(date +%s%N) / 1000 % $microseconds ))

Deleting the PID files exit the program

if [ ! -f /var/run/cron-ms/$$ ] then exit fi

Run all the programs in the directory in parallel

for program in /etc/cron-ms/$1/* ; do $program &> /dev/null & done

exec $0 $1

Hello, here you can find the build directory for the Busybox package.

https://github.com/arduino/openwrt-yun/tree/master/package/busybox

In the Makefile you can find where to download the busybox source code, and if you want to modify it you can create your own patchfile.

opkg update
opkg install coreutils-sleep
/usr/bin/sleep --help
Usage: /usr/bin/sleep NUMBER[SUFFIX]...
  or:  /usr/bin/sleep OPTION
Pause for NUMBER seconds.  SUFFIX may be 's' for seconds (the default),
'm' for minutes, 'h' for hours or 'd' for days.  Unlike most implementations
that require NUMBER be an integer, here NUMBER may be an arbitrary floating
point number.  Given two or more arguments, pause for the amount of time
specified by the sum of their values.
/usr/bin/sleep  0.001

Please modify your code with code tag.

That worked! Did you just create that or just know about it? BTW - needed to delete the symlink to busybox to make it work. /bin/sleep

mperkel: That worked! Did you just create that or just know about it? BTW - needed to delete the symlink to busybox to make it work. /bin/sleep

No need delete the symlink to busybox, Use

/usr/bin/sleep

In case remove coreutils-sleep, sleep still works.

I just noticed something else. The date command is also limited. %N doesn't work.

http://forum.arduino.cc/index.php?topic=279387.msg1964009#msg1964009

Thanks a lot - that fixed the date problem. I'm going to need to rewrite this using sleep instead of usleep .

mperkel:
That worked! Did you just create that or just know about it? BTW - needed to delete the symlink to busybox to make it work. /bin/sleep

@mperkel,
you also want to leave it in place as it is a “stock”/default utility. There are likely tools that depend on it, and you won’t know until they break. Use the suggestion give by SonnyYu.

Jesse