Posted: Mon Oct 31, 2022 4:57 Post subject: [Solved] (crontabs) ORPHAN (no passwd entry)
Hi There!
I’m using DD-WRT v3.0-r49626 std (08/03/22) on a WRT-3200ACM, see its specs on this png:
I’m trying to run a cron job set up on Administration/Management tab at Cron/Additional Jobs (Cron Enabled) with the following 5 lines (adapted from Angela D):
On Administration/Management Tab:
Cron
Cron Enabled
Additional Jobs:
The first line (root curl…) works as expected, hosts file is copied to /tmp/ad-hosts. But none of the remaining did. No line is appended to it (/tmp/ad-hosts).
Enabling syslogs allowed me to check /tmp/var/log/messages:
Code:
root@OS-DDWRT:~# cat /tmp/var/log/messages | grep cron
Oct 30 23:47:00 OS-DDWRT cron.info cron[11945]: (crontabs) ORPHAN (no passwd entry)
dd wrt (crontabs) ORPHAN (no passwd entry) 2000..2022
to no avail. Sure some topics popped up but not sure whether any of them applies to this current issue.
Also I noticed
Code:
service dnsmasq restart
did not work under cron job. But it did by running it manually:
Code:
root@OS-DDWRT:~# service dnsmasq restart
[smartdns] : daemon successfully stopped
[dnsmasq] : daemon successfully stopped
[smartdns] : daemon successfully started
[dnsmasq] : daemon successfully started
root@OS-DDWRT:~#
root@OS-DDWRT:~# cat /tmp/var/log/messages | grep 00:38
Oct 31 00:38:25 OS-DDWRT user.info : [smartdns] : daemon successfully stopped
Oct 31 00:38:25 OS-DDWRT user.info : [dnsmasq] : daemon successfully stopped
Oct 31 00:38:25 OS-DDWRT daemon.info dnsmasq[15993]: exiting on receipt of SIGTERM
Oct 31 00:38:25 OS-DDWRT user.info : [smartdns] : daemon successfully started
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: started, version 2.87test8 cache disabled
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: compile time options: IPv6 GNU-getopt no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua no-TFTP no-conntrack ipset no-nftset no-auth cryptohash DNSSEC loop-detect inotify no-dumpfile
Oct 31 00:38:26 OS-DDWRT daemon.warn dnsmasq[16707]: warning: ignoring resolv-file flag because no-resolv is set
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq-dhcp[16707]: DHCP, IP range 192.168.15.16 -- 192.168.15.47, lease time 1d
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using nameserver 127.0.0.1#6053
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using nameserver 88.198.70.38#53
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using nameserver 88.198.70.39#53
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for Workgroup
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for test
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for onion
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for localhost
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for local
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for invalid
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: using only locally-known addresses for bind
Oct 31 00:38:26 OS-DDWRT user.info : [dnsmasq] : daemon successfully started
Oct 31 00:38:26 OS-DDWRT daemon.info dnsmasq[16707]: read /etc/hosts - 4 addresses
Oct 31 00:38:26 OS-DDWRT daemon.err dnsmasq[16707]: bad address at /tmp/ad-hosts line 22
Oct 31 00:38:27 OS-DDWRT daemon.info dnsmasq[16707]: read /tmp/ad-hosts - 157818 addresses
root@OS-DDWRT:~#
Nevermind the line above “bad address at /tmp/ad-hosts line 22”, it’s a typo in the original hosts file, Steven Black has already been notified about it.
It is important that you include "root" before the command, otherwise the command will not run as specified. The examples, in external links above or elsewhere, leave off prefixing commands with "root". External examples outside this Wiki and DD-WRT, are designed for common multi-account Linux systems: cron normally runs instructions inside crontab files as dependent on whichever user created them. Without using "root", your test only works in telnet or ssh (eg Putty) because you already logged in as root.
It is important that you include "root" before the command, otherwise the command will not run as specified. The examples, in external links above or elsewhere, leave off prefixing commands with "root". External examples outside this Wiki and DD-WRT, are designed for common multi-account Linux systems: cron normally runs instructions inside crontab files as dependent on whichever user created them. Without using "root", your test only works in telnet or ssh (eg Putty) because you already logged in as root.
Thank you for the tip. I guess I did it as you advised:
Code:
#!/bin/sh
# hosts_append.sh
# Script to load hosts file, append lines to it and restart dnsmasq service
# Placed at /tmp/hosts_append.sh
# chmod 700 /tmp/hosts_append.sh
# Run as a cron job "1 0 * * * root /tmp/hosts_append.sh"
curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
service dnsmasq restart
Code:
root@OS-DDWRT:~# ls -al /tmp/hosts_append.sh
-rwx------ 1 root root 506 Oct 31 11:32 /tmp/hosts_append.sh
root@OS-DDWRT:~#
I run as root and it works:
Code:
root@OS-DDWRT:~# /tmp/hosts_append.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5578k 100 5578k 0 0 9969k 0 --:--:-- --:--:-- --:--:-- 9979k
[smartdns] : daemon successfully stopped
[dnsmasq] : daemon successfully stopped
[smartdns] : daemon successfully started
[dnsmasq] : daemon successfully started
root@OS-DDWRT:~#
root@OS-DDWRT:~# tail -10 /tmp/var/log/messages
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for test
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for onion
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for localhost
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for local
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for invalid
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: using only locally-known addresses for bind
Oct 31 12:49:48 OS-DDWRT user.info : [dnsmasq] : daemon successfully started
Oct 31 12:49:48 OS-DDWRT daemon.info dnsmasq[26593]: read /etc/hosts - 4 addresses
Oct 31 12:49:48 OS-DDWRT daemon.err dnsmasq[26593]: bad address at /tmp/ad-hosts line 22
Oct 31 12:49:49 OS-DDWRT daemon.info dnsmasq[26593]: read /tmp/ad-hosts - 157819 addresses
root@OS-DDWRT:~#
root@OS-DDWRT:~# tail -5 /tmp/ad-hosts
# 0.0.0.0 example.com
0.0.0.0 fonts.gstatic.com
0.0.0.0 graph.facebook.com
0.0.0.0 ads.linkedin.com
root@OS-DDWRT:~#
But running it as a cron job is yet to succeed:
Code:
root@OS-DDWRT:~# tail -10 /tmp/var/log/messages
Oct 31 13:01:29 OS-DDWRT daemon.debug ntpclient[28205]: Connecting to 2.north-america.pool.ntp.org [206.108.0.132] ...
Oct 31 13:01:29 OS-DDWRT user.info : [scc] : speedchecker successfully stopped
Oct 31 13:01:29 OS-DDWRT user.info : [speedchecker] : client started
Oct 31 13:01:29 OS-DDWRT daemon.info ntpclient[28205]: Time set from 2.north-america.pool.ntp.org [206.108.0.132].
Oct 31 13:01:29 OS-DDWRT daemon.info process_monitor[28204]: Cyclic NTP Update success (servers 2.north-america.pool.ntp.org)
Oct 31 13:01:29 OS-DDWRT daemon.info process_monitor[28204]: Local timer delta is 7160707297096761344
Oct 31 13:01:29 OS-DDWRT daemon.debug process_monitor[28204]: We need to re-update after 3600 seconds
Oct 31 13:01:29 OS-DDWRT daemon.info process_monitor[28204]: [process_monitor] : set timer: 3600 seconds, callback: ntp_main()
Oct 31 13:01:30 OS-DDWRT daemon.info hostapd: wlan1: STA 64:51:06:73:e7:16 IEEE 802.11: authenticated
Oct 31 13:02:00 OS-DDWRT cron.info cron[27406]: (crontabs) ORPHAN (no passwd entry)
root@OS-DDWRT:~#
I also changed to:
Code:
#!/bin/sh
# hosts_append.sh
# Script to load hosts file, append lines to it and restart dnsmasq service
# Placed at /tmp/hosts_append.sh
# chmod 700 /tmp/hosts_append.sh
# Run as a cron job "1 0 * * * /tmp/.hosts_append"
root curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
root echo 0.0.0.0 fonts.gstatic.com | tee -a /tmp/ad-hosts
root echo 0.0.0.0 graph.facebook.com | tee -a /tmp/ad-hosts
root echo 0.0.0.0 ads.linkedin.com | tee -a /tmp/ad-hosts
root service dnsmasq restart
And now on Administration/Management/Cron/Additional Jobs I have:
Code:
1 0 * * * /tmp/hosts-append.sh
instead of
Code:
1 0 * * * root /tmp/hosts-append.sh
But the outcome is the same ((crontabs) ORPHAN (no passwd entry)):
Code:
root@OS-DDWRT:~# tail -10 /tmp/var/log/messages
Oct 31 13:19:53 OS-DDWRT user.info : [process_monitor] : successfully started
Oct 31 13:19:53 OS-DDWRT daemon.debug ntpclient[31406]: Connecting to 2.north-america.pool.ntp.org [206.108.0.132] ...
Oct 31 13:19:53 OS-DDWRT user.info : [scc] : speedchecker successfully stopped
Oct 31 13:19:53 OS-DDWRT user.info : [speedchecker] : client started
Oct 31 13:19:53 OS-DDWRT daemon.info ntpclient[31406]: Time set from 2.north-america.pool.ntp.org [206.108.0.132].
Oct 31 13:19:53 OS-DDWRT daemon.info process_monitor[31405]: Cyclic NTP Update success (servers 2.north-america.pool.ntp.org)
Oct 31 13:19:53 OS-DDWRT daemon.info process_monitor[31405]: Local timer delta is 7160712038740656128
Oct 31 13:19:53 OS-DDWRT daemon.debug process_monitor[31405]: We need to re-update after 3600 seconds
Oct 31 13:19:53 OS-DDWRT daemon.info process_monitor[31405]: [process_monitor] : set timer: 3600 seconds, callback: ntp_main()
Oct 31 13:20:00 OS-DDWRT cron.info cron[30609]: (crontabs) ORPHAN (no passwd entry)
root@OS-DDWRT:~#
So not exactly sure where to apply root explicitly.
What I am missing?
Thanks! _________________ DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
This is an invalid syntax, which causes the commands to be executed with the user "echo".
And a user "echo" does not exist.
Code:
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
Thank you ho1Aetoo!
I think you mean username root in the cron job, right?
Actually, there was a couple of typos in my posting.
The syntax was correct on both cron tab page and the script:
On cron tab:
Code:
1 0 * * * root /tmp/hosts_append.sh
On the script:
Code:
root@OS-DDWRT:~# cat /tmp/hosts_append.sh
#!/bin/sh
# hosts_append.sh
# Script to load hosts file, append lines to it and restart dnsmasq service
# Placed at /tmp/hosts_append.sh
# chmod 700 /tmp/hosts_append.sh
# Run as a cron job "1 0 * * * /tmp/hosts_append.sh"
curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
service dnsmasq restart
root@OS-DDWRT:
Despite that, cron was yet to work as it should:
Code:
root@OS-DDWRT:~# tail -5 /tmp/var/log/messages
Oct 31 22:00:57 OS-DDWRT daemon.info process_monitor[14601]: Local timer delta is 7160846316598198272
Oct 31 22:00:57 OS-DDWRT daemon.debug process_monitor[14601]: We need to re-update after 3600 seconds
Oct 31 22:00:57 OS-DDWRT daemon.info process_monitor[14601]: [process_monitor] : set timer: 3600 seconds, callback: ntp_main()
Oct 31 22:00:58 OS-DDWRT daemon.info hostapd: wlan1: STA 64:51:06:73:e7:16 IEEE 802.11: authenticated
Oct 31 22:01:00 OS-DDWRT cron.info cron[13788]: (crontabs) ORPHAN (no passwd entry)
root@OS-DDWRT:~#
Then I decided to run:
Code:
stopservice crond && startservice crond
,
recreated the script and...
Voilá! All is working like a charm.
Code:
root@OS-DDWRT:/etc# cat /tmp/hosts_append.sh
#!/bin/sh
# hosts_append.sh
# Script to load hosts file, append lines to it and restart dnsmasq service
# Placed at /tmp/hosts_append.sh
# chmod 700 /tmp/hosts_append.sh
# Run as a cron job "1 0 * * * /tmp/hosts_append.sh"
curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
service dnsmasq restart
root@OS-DDWRT:/etc#
root@OS-DDWRT:/etc# ls -al /tmp/hosts_append.sh
-rwx------ 1 root root 483 Nov 1 11:32 /tmp/hosts_append.sh
root@OS-DDWRT:/etc#
root@OS-DDWRT:/etc# cat /tmp/cron.d/cron_jobs
* * * * * root /tmp/hosts_append.sh
root@OS-DDWRT:/etc#
root@OS-DDWRT:~# cat /tmp/var/log/messages | grep 14:15
Nov 1 14:15:01 OS-DDWRT user.info : [smartdns] : daemon successfully stopped
Nov 1 14:15:01 OS-DDWRT user.info : [dnsmasq] : daemon successfully stopped
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18493]: exiting on receipt of SIGTERM
Nov 1 14:15:01 OS-DDWRT user.info : [smartdns] : daemon successfully started
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: started, version 2.87test8 cache disabled
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: compile time options: IPv6 GNU-getopt no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua no-TFTP no-conntrack ipset no-nftset no-auth cryptohash DNSSEC loop-detect inotify no-dumpfile
Nov 1 14:15:01 OS-DDWRT daemon.warn dnsmasq[18512]: warning: ignoring resolv-file flag because no-resolv is set
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq-dhcp[18512]: DHCP, IP range 192.168.15.16 -- 192.168.15.47, lease time 1d
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using nameserver 127.0.0.1#6053
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using nameserver 88.198.70.38#53
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using nameserver 88.198.70.39#53
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for Workgroup
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for test
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for onion
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for localhost
Nov 1 14:15:01 OS-DDWRT user.info : [dnsmasq] : daemon successfully started
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for local
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for invalid
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: using only locally-known addresses for bind
Nov 1 14:15:01 OS-DDWRT daemon.info dnsmasq[18512]: read /etc/hosts - 4 addresses
Nov 1 14:15:01 OS-DDWRT daemon.err dnsmasq[18512]: bad address at /tmp/ad-hosts line 22
Nov 1 14:15:02 OS-DDWRT daemon.info dnsmasq[18512]: read /tmp/ad-hosts - 157819 addresses
root@OS-DDWRT:~#
root@OS-DDWRT:~# tail /tmp/ad-hosts
#
# The contents of this file (containing a listing of additional domains in
# 'hosts' file format) are appended to the unified hosts file during the
# update process. For example, uncomment the following line to block
# 'example.com':
Since you saved the script in /tmp it will be lost on a router reboot.
If you want it to be permanent then you must either put the script on a USB stick or activate jffs2 and save the script in /jffs.
Or save as custom, startup, firewall provided there is no issues with remaining nvram space. _________________ "The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost
"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio
Save as firewall survives the end of times and the whatever is next when cockroaches take over. oops too late.
NAP, thank you for your help! You're right on the spot, too.
My guess is either the nvram or the fw approach are pretty much the same thing, right? _________________ DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
.rc_startup, .rc_custom, .rc_usb, .rc_firewall using the Administration -> Commands page; whichever script should be in your crontab, nothing about nvram, with root as user. _________________ "The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost
"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio
Thank you so much for all the tips and tricks. They worked!
This is the final settings which are running as expected:
On Administration/Commands/Startup:
Code:
#!/bin/sh
# /tmp/.rc_startup
# Startup script to load hosts file, append lines to it and restart dnsmasq service
# Placed at .rc_startup variable
# chmod 700 /tmp/.rc_startup
# Run as a cron job '1 0 * * * root /tmp/.rc_startup'
curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts
# echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
service dnsmasq restart
On Administration/Management/Additional Jobs:
Code:
1 0 * * * root /tmp/.rc_startup
Just FYI:
I commented out the line fonts.gstatic.com for the time being because I noticed it plays some roles within Google Calendar JavaScript functions. I just learned that, as per this web site, gstatic has a special role in helping the content on Google to load faster from their CDN or content delivery network, and other stuff. So I do not see any harm it may cause, being it a legitimate Google service that facilitates reduced bandwidth usage and increased network performance.
I did not do the same to the next two other echos because so far I'm yet to notice any issues.
Again, thank you all for your invaluable help! _________________ DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...