Yes — you're consuming memory with those scripts. You've actually got two processes running, using memory:
- a shell (e.g., bash)
sleep is going to be extremely lightweight, but the shell may consume a few megabytes of memory. On my system an idle non-interactive bash consumes ~1MiB and a sleep 0.7MiB. You can check
top (look at the RSS column)—though a lot of that total is actually things like libraries which are shared between all processes using them. All in all, it's likely <1MiB each.
On Linux, you can get more details from
Vm* ones are of interest here. For example:
bash -c 'grep Vm /proc/$$/status'
VmPeak: 13380 kB
VmSize: 13380 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 972 kB
VmRSS: 972 kB
VmData: 220 kB
VmStk: 132 kB
VmExe: 208 kB
VmLib: 2320 kB
VmPTE: 48 kB
VmPMD: 12 kB
VmSwap: 0 kB
You can see total RSS (amount of used RAM) of 972 kB, of which 220 kB is "data" (typically not shared) and 132 kB is stack (also not shared). So each extra bash left running is pretty small.
Some advice: if you're having to do a bunch of workarounds like this... why can't you use cron? That's a simpler, cleaner approach, far less likely to have unexpected bugs (quick! How does
sleep 1d handle a daylight saving time change? What happens if your sleep returns early because it was SIGTERM'd as part of a reboot/shutdown?). If your sysadmin is concerned about unauthorized people scheduling cron jobs, point him/her to
/etc/cron.deny; those are documented in crontab(1).