[Solved] (crontabs) ORPHAN (no passwd entry)

Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Mon Oct 31, 2022 4:57    Post subject: [Solved] (crontabs) ORPHAN (no passwd entry) Reply with quote
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:

Code:
1 0 * * * root curl -k -o /tmp/ad-hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
1 0 * * * echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
1 0 * * * echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
1 0 * * * echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
1 0 service dnsmasq restart

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)

I googled
Quote:
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.

As a work around I also tried (as suggested by this link), but no good either:

Code:
1 0 * * * echo 0.0.0.0 fonts.gstatic.com | tee -a /tmp/ad-hosts
1 0 * * * echo 0.0.0.0 graph.facebook.com | tee -a /tmp/ad-hosts
1 0 * * * echo 0.0.0.0 ads.linkedin.com | tee -a /tmp/ad-hosts


Any thoughts deeply appreciated.

_________________
DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...


Last edited by Ostddwrt on Fri Nov 18, 2022 21:36; edited 1 time in total
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12837
Location: Netherlands

PostPosted: Mon Oct 31, 2022 10:50    Post subject: Reply with quote
I would put everything in a script and then run that script as cron job.

For Cron see:
https://wiki.dd-wrt.com/wiki/index.php/CRON

Quote:
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.

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Mon Oct 31, 2022 16:28    Post subject: Reply with quote
egc wrote:
I would put everything in a script and then run that script as cron job.

For Cron see:
https://wiki.dd-wrt.com/wiki/index.php/CRON

Hi egc!

Quote:
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...
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2927
Location: Germany

PostPosted: Mon Oct 31, 2022 16:36    Post subject: Reply with quote
You have to specify root as the user in the crontab.
It is always necessary to specify a user.

1 0 * * * echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
1 0 * * echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
1 0 * * echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
1 0 service dnsmasq restart

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
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Tue Nov 01, 2022 17:56    Post subject: Reply with quote
ho1Aetoo wrote:
You have to specify root as the user in the crontab.
It is always necessary to specify a user.

1 0 * * * echo 0.0.0.0 fonts.gstatic.com >> /tmp/ad-hosts
1 0 * * echo 0.0.0.0 graph.facebook.com >> /tmp/ad-hosts
1 0 * * echo 0.0.0.0 ads.linkedin.com >> /tmp/ad-hosts
1 0 service dnsmasq restart

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. Very Happy

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':

# 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:~#
root@OS-DDWRT:~# nvram show | grep =$ | wc -l
size: 41549 bytes (89523 left)
375
root@OS-DDWRT:~#


My remaining question is, the script will be gone when stopservice crond && startservice crond is launched, right?...

So would it be a good idea to have it saved at /etc/config/hosts_append.startup?...

Thanks a lot!

_________________
DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
ho1Aetoo
DD-WRT Guru


Joined: 19 Feb 2019
Posts: 2927
Location: Germany

PostPosted: Tue Nov 01, 2022 18:06    Post subject: Reply with quote
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.
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1899

PostPosted: Tue Nov 01, 2022 19:18    Post subject: Reply with quote
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

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Tue Nov 01, 2022 20:53    Post subject: Reply with quote
Save as firewall survives the end of times and the whatever is next when cockroaches take over. oops too late.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Wed Nov 02, 2022 2:24    Post subject: Reply with quote
ho1Aetoo wrote:
Since you saved the script in /tmp it will be lost on a router reboot.


Yep, you're right. That's what happened.

ho1Aetoo wrote:
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.


Yeah, it's an option. But first I will investigate all possible options available.

Thanks!

_________________
DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Wed Nov 02, 2022 2:41    Post subject: Reply with quote
dale_gribble39 wrote:
Or save as custom, startup, firewall provided there is no issues with remaining nvram space.


What I did in the meantime was the NVRAM method from here:
Code:
nvram set rc_startup="
 <command 1>
 <command 2>
 ...
 <command n>
 "


And looks like it's there:

Code:
root@OS-DDWRT:~# nvram get rc_startup
#!/bin/sh
# /etc/hosts_append.sh
# Startup script to load hosts file, append lines to it and restart dnsmasq service
# Placed at nvram rc_startup variable
# 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:~#


Problem is I didn't find a Howto to place it in a cron job. Neither one of the below worked:

Code:
* * * * * root nvram rc_startup


Code:
* * * * * nvram root rc_startup


Code:
* * * * * nvram rc_startup

_________________
DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Wed Nov 02, 2022 2:48    Post subject: Reply with quote
the-joker wrote:
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...
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1899

PostPosted: Wed Nov 02, 2022 3:28    Post subject: Reply with quote
.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

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
Ostddwrt
DD-WRT Novice


Joined: 31 Aug 2018
Posts: 18
Location: FL

PostPosted: Fri Nov 18, 2022 20:33    Post subject: Reply with quote
@dale_gribble39, @the-joker, @ho1Aetoo, @egc

Hi to you all!

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! Very Happy

_________________
DD-WRT V3.0-r49626 std (08/03/22) on WRT3200ACM and flying...
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum