D-Link Forums

The Graveyard - Products No Longer Supported => D-Link Storage => DNS-325 => Topic started by: japa-fi on February 21, 2012, 11:54:43 AM

Title: crontab customisation
Post by: japa-fi on February 21, 2012, 11:54:43 AM
Is there a way to add permanent entries to crontab?
If I manually add entries to crontab, they are overwritten the next time I do something via the NAS web interface.
Title: Re: crontab customisation
Post by: japa-fi on May 13, 2012, 09:35:00 AM
/etc/NAS_CFG/config.xml contains lot of stuff, including what seems to be used to build the crontab entries
I just need to know what program uses this file as their source to build the crontab.


The xml entries from the file are:
Code: [Select]
<crond>
                        <list>
                                <count>4</count>
                                <name id="1">stime</name>
                                <name id="2">rtc</name>
                                <name id="3">user.log</name>
                                <name id="4">smart</name>
                        </list>
                        <stime>
                                <count>1</count>
                                <item id="1">
                                        <method>3</method>
                                        <1>30</1>
                                        <2>2</2>
                                        <3>*</3>
                                        <4>*</4>
                                        <5>*</5>
                                        <run>/usr/sbin/stime&amp;</run>
                                </item>
                        </stime>

                        <rtc></rtc>
                        <user.log>
                                <count>1</count>
                                <item id="1">
                                        <method>1</method>
                                        <1>*/10</1>
                                        <2>*</2>
                                        <3>*</3>
                                        <4>*</4>
                                        <5>*</5>
                                        <run>/usr/sbin/rlog /var/log/user.log 800</run>
                                </item>
                        </user.log>
                        <smart>
                                <count>1</count>
                                <item id="1">
                                        <method>2</method>
                                        <1>0</1>
                                        <2>20</2>
                                        <3>*</3>
                                        <4>*</4>
                                        <5>0</5>
                                        <run>/usr/sbin/smart_test -a -l</run>
                                        <slot>0</slot>
                                </item>
                        </smart>
                </crond>
Title: Re: crontab customisation
Post by: JonBoyWalton on January 21, 2013, 03:36:55 PM
I've been looking for the same thing. 

It looks like /usr/sbin/system_init copies the file over from /usr/local/config/ at boot so making changes and copying the file back to /usr/local/config/ should ensure it survives a reboot.

I've added an entry.  Once my raid mirror has finished rebuilding I'll reboot and see if crontab survives.
Title: Re: crontab customisation
Post by: japa-fi on January 24, 2013, 11:20:29 AM
I've hacked around the problem.
I've created a text file: add_to_crontab

As I have fun_plug installed, to the startup script as the last step, I've put command:
crontab /path/to/my/file/add_to_crontab

Thus any changes I want to crontab, I edit add_to_crontab and then load that file via crontab command.

Title: Re: crontab customisation
Post by: JonBoyWalton on January 26, 2013, 02:04:00 AM
I can confirm adding additional entries to the config.xml in /usr/local/config works.

But using a separate file as you have done is probably safer - I imagine if you mess up the config.xml then all sorts of things will go wrong.

Title: Re: crontab customisation
Post by: Lardo16 on May 28, 2013, 03:56:37 AM
I can confirm adding additional entries to the config.xml in /usr/local/config works.

But using a separate file as you have done is probably safer - I imagine if you mess up the config.xml then all sorts of things will go wrong.


Would you be able to post a sample of what you inserted for the next job.
I'm pretty sure i can replicate everything except for <method>(Numericalvalue)</method> because i can't find the pattern with that line.
everything else in the .xml has a distinct pattern that could be replicated.
Title: Re: crontab customisation
Post by: JonBoyWalton on May 28, 2013, 02:38:33 PM
I have used a method value of 1


I created an entry to call fetchmail.  Added the fetchmail line in the list:


 <crond>
                        <list>
                                <count>4</count>
                                <name id="1">stime</name>
                                <name id="2">rtc</name>
                                <name id="3">user.log</name>
                                <name id="4">fetchmail</name>
                        </list>


And then created a fetchmail entry as below:


                        <fetchmail>
                                <count>1</count>
                                <item id="1">
                                        <method>1</method>
                                        <1>*/8</1>
                                        <2>*</2>
                                        <3>*</3>
                                        <4>*</4>
                                        <5>*</5>
                                        <run>/opt/bin/fetchmail -f /opt/etc/fetc
                                </item>
                        </fetchmail>