Date -d "+x days" not working

I am a bit new to OpenWRT, but I don't understand why it does not have this functionality. I cannot date -d anything beyond the time of the current day. I keep getting "invalid date +1 days". This functionality exists in many other linux distros. Why not this one? This makes many scripts I have unusable. Any way around this?

date(1) on OpenWrt is typically provided by busybox, which implements a subset of GNU coreutil's implementation of date(1) for size reasons. busybox typically follows the minimum requirements set by POSIX/ SUSv4 and avoids implementing 'optional' features commonly found in full-featured GNU or BSD userland implementations.

While dealing with embedded devices in the 4 to 8 MB range of main storage, size is king and optional features are just getting in the way. There is a reason why e.g. Debian states 2 GB main storage and 128 MB RAM as its absolutely minimum system requirements (and that's already pretty optimistic, particularly the figures for the RAM), while OpenWrt has to deal with devices starting at 4 MB flash and 32 MB RAM (yes, we are moving to 8 MB flash and 64 MB RAM as minimum system requirements for OpenWrt, but you still see the problem).

If necessary, coreutils-date is available for installing, but you should reconsider if this is a good option (sysupgrades will revert to busybox date, so you're up with 'unexpected' behaviour if you rely on GNU extensions for important/ non-interactive behaviour).


Ok. I did a little research and it seems that busybox does support seconds since epoch. I could do something like date -d "@$(( $(date +%s) + 86400 ))" instead of date -d "+1days". Thanks for the help

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.