• March 28, 2024, 06:09:45 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

This Forum Beta is ONLY for registered owners of D-Link products in the USA for which we have created boards at this time.

Author Topic: crontab customisation  (Read 8966 times)

japa-fi

  • Level 1 Member
  • *
  • Posts: 23
crontab customisation
« 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.
Logged

japa-fi

  • Level 1 Member
  • *
  • Posts: 23
Re: crontab customisation
« Reply #1 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>
Logged

JonBoyWalton

  • Level 1 Member
  • *
  • Posts: 3
Re: crontab customisation
« Reply #2 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.
Logged

japa-fi

  • Level 1 Member
  • *
  • Posts: 23
Re: crontab customisation
« Reply #3 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.

Logged

JonBoyWalton

  • Level 1 Member
  • *
  • Posts: 3
Re: crontab customisation
« Reply #4 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.

Logged

Lardo16

  • Level 1 Member
  • *
  • Posts: 1
Re: crontab customisation
« Reply #5 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.
Logged

JonBoyWalton

  • Level 1 Member
  • *
  • Posts: 3
Re: crontab customisation
« Reply #6 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>

Logged