Additions to Crontab Reverting

Yes, but from memory is not the same as the actual file. Sorry, as someone who has spent a long time in this field, I know memory does not catch the little typos or missing brackets and stuff like that - only a real backed up file does that. So trying to figure out what went wrong depending on your memory is useless.

1 Like

Hi!

I’m tempted to try siamese’s solution but there are several things that are not entirely clear to me.

  1. In my (unmodified) config.xml the tag does neither reflect the number of entries nor the number of entries minus one:

    6 user.log stime wd_crontab app_get_info auto_fw random_check fw_available user_expire_chk

 2) What does the tag stand for? All jobs seem to use “3”, except for user.log which uses “1”. Does this have to do with the minute spec (i.e., every 10 mins => method 1 vs. 30 mins past every full hour => method 3)???

<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 -s /usr/local/modules/files/syslog_rotate.conf</run>
	</item>
</user.log>

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

 3) I noticed that “&” is escaped using “&”. What other characters will need escaping? I suppose the “>” for output redirection is among them.

Would be great if someone could shed a light on all this!

In the latest firmware there are 7 entries which match the number of jobs below that…I am not sure where you got the 8th one from. Plus your list looks a bit different. Are you on the latest firmware for EX2? I got this from straight from the source code file of the latest firmware. This is what it should look like:

<list>
	<count>7</count>
	<name id="1">user.log</name>
	<name id="2">stime</name>
	<name id="3">wd_crontab</name>
	<name id="4">fw_available</name>
	<name id="5">app_get_info</name>
	<name id="6">recycle_bin_clear</name>
	<name id="7">chk_wfs_download</name>
</list>

Not sure what the method is used for, but I would use method 3 since that’s what all other jobs are using except the first one.

I would only escape the ampersand - anything like output redirection should be inside the script that the job will call - it should not be put in the run line.

I’m running the latest firmware with auto firmware update turned off.  Here is whats in my config.xml;

                             5                 user.log                 stime                 wd\_crontab                 app\_get\_info                 recycle\_bin\_clear                 random\_check                 fw\_available                 user\_expire\_chk             

Thanks for that listing, Vertech1. So coco-loco’s listing is indeed accurate for the latest firmware. Hmm…I got the config.xml from the source code, but apparently it seems that’s not what gets installed. The other oddity I observe from both your and coco-loco’ listings are that you two have different values for count tag. Not sure what’s going on with that.

Found a great solution without modifying WD Configs or something simmiliar. No reverting on it.

See:  http://community.wd.com/t5/WD-My-Cloud-EX2/Crontab-on-MyCloud-EX2/m-p/860951/highlight/false#M2930

Only Problem now is on Reboot. On a Reboot it reverts its / directory. Anyone knows from where it copies over this? It should be possible to add the Files to this origin Dir.

How I solved the wipe on reboot issue: enable Transmission. Than edit /mnt/HD/HD_a2/Nas_Prog/Transmission/init.sh by adding a custom script that does whatever you want. I also added a ‘sleep 60’ before my custom script to make sure everything was intialized before my custom script runs. I use it to put the fan in the lowest speed after each reboot.

1 Like

Thanks, this is the only solution worked for me. I basically created a script on a hard drive (/mnt/HD/HD_a2/update-cron.sh) which internally adds some lines to root’s cron file and reloads crontab. This way i could add different reoccuring jobs, which were not deleted after restart:

#!/bin/sh
echo "0 3 * * * /mnt/HD/HD_a2/backup/download-all-backups.sh" >> /var/spool/cron/crontabs/root
echo "*/1 * * * * touch /tmp/hello-world.txt" >> /var/spool/cron/crontabs/root
crontab /var/spool/cron/crontabs/root

The line added to /mnt/HD/HD_a2/Nas_Prog/Transmission/init.sh was:

/mnt/HD/HD_a2/update-cron.sh

Hope it helps.

Thanks Alexey. This really help me

Hello Everyone, I realize this is thread is a bit dated, but I wanted to see if I could still get some help. I followed Alexey’s Tuturial, and I have my two custom entries showing up after a reboot of the mycloud ex2 ultra, (the back up job, and the hello world touch).

My problem is, that another process is killing those cron entries at midnight every night. The cron job ouput after a reboot that looks good looks like this:

root@donkeykong root # crontab -l
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
*/30 * * * * /usr/sbin/quota_monitor &
*/10 * * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
01 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
58 2 * * * /usr/local/sbin/PullWdlogConfig.sh
30 0 * * 1 logwdmsg -e &
0 3 * * * logwdmsg -o &
01 3 * * * /usr/local/sbin/LogDataSize.sh
00 3 * * * /usr/sbin/wd_rotate.sh
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
30 2 * * * /usr/sbin/stime&
0 3 * * * wd_crontab.sh&
0 4 * * * auto_fw -a -c&
0 0 * * * auto_clear_recycle_bin.sh &
30 3 * * * /usr/sbin/chk_wfs_download&
0 0 * * * random_check -s &
35 9 * * * auto_fw -c 1 &
0 0 * * * expire.sh

          • sysinfo_update.sh
            0 3 * * 1 getHddWhiteList.sh
            0 16 * * 5 /mnt/HD/HD_a2/scripts/zv_sync_vze.php
            */1 * * * * touch /tmp/hello-world.txt

The last two entries are my custom script and the hello world. The next morning the crontab looks like this:

root@donkeykong root # crontab -l
0 3 * * * /usr/sbin/daily_log_upload.sh &
0 3 * * * /usr/sbin/traceroute_wd.sh &
*/30 * * * * /usr/sbin/quota_monitor &
*/10 * * * * /usr/sbin/rlog -s /usr/local/modules/files/syslog_rotate.conf
01 */8 * * * [ -f /etc/init.d/atop ] && /etc/init.d/atop rotate
30 0 * * * /usr/local/sbin/ssl_cert_job.sh start > /var/log/ssl_cert_cron.out 2>&1
58 2 * * * /usr/local/sbin/PullWdlogConfig.sh
30 0 * * 1 logwdmsg -e &
0 3 * * * logwdmsg -o &
01 3 * * * /usr/local/sbin/LogDataSize.sh
00 3 * * * /usr/sbin/wd_rotate.sh
30 0 * * 1 /usr/sbin/wdappmgr_log_stats.py > /dev/null 2>&1 &
30 2 * * * /usr/sbin/stime&
0 3 * * * wd_crontab.sh&
0 4 * * * auto_fw -a -c&
0 0 * * * auto_clear_recycle_bin.sh &
30 3 * * * /usr/sbin/chk_wfs_download&
0 0 * * * random_check -s &
35 9 * * * auto_fw -c 1 &
0 0 * * * expire.sh

          • sysinfo_update.sh
            0 3 * * 1 getHddWhiteList.sh

Looking at the Cron Jobs, the scripts that run at midnight are the obvious culprits:
0 0 * * * auto_clear_recycle_bin.sh &
0 0 * * * random_check -s &
0 0 * * * expire.sh

I have tried editing /usr/local/config/config.xml and putting a comment in front of each of these entries, but the next morning the comment does not exist and the cron entries revert back to the list without my custom entries, so the cron entries have to be coming from somewhere else. Has anyone figured this out?

Hi all together,

I had the same Issue like tristan but I found the following workaround.

First of all, thank you for your research. That saved me some of time.
I’ve got a Personal Cloud with firmware 2.21.126.
I tried to configure some jobs with editing the /usr/local/config/config.xml. That worked fine until I added more than one entry. With two or more custom entries the nas did not startup anymore. So I had to do the 40s-reset. After a while with try and error I found a workaround.

  1. on the web admin interface - create some dummy entries for internal backup. This will create a new entry <internal_backup> in /usr/local/config/config.xml

my config.xml now looked like this:

	
		6
		stime
		wd_crontab
		app_get_info
		recycle_bin_clear
		chk_wfs_download
		internal_backup
		random_check
		fw_available
		user_expire_chk
		
...

		
			3
			<1>0
			<2>0
			<3>*
			<4>*
			<5>*
			internal_backup -a test1 -c jobrun &
		
		
			3
			<1>0
			<2>1
			<3>*
			<4>*
			<5>*
			internal_backup -a test2 -c jobrun &
		

  1. now you can abuse the entry <internal_backup> for your own job. You can delete the dummy backup-jobs via web interface. The tag <internal_backup> will remain in config.xml.

  2. just add your own jobs by abusing <internal_backup>. It seems that’s some kind of special tag, that allows to add items without limit

  3. restart

This trick sounded so clever. Mine is a MyCloud with version 2.21.126

I followed your steps and it worked like a charm.

After the reboot, when I do “crontab -l”, I can see that there is a new line

30 * * * * /shares/MyData/daily_bk.sh &

I have done this. But after time it sets to default xml. Any idea?

I have not deleted job internal backup from web interface. It caused the deleting.

I am curious…but I won’t be holding my breath for your solution to the persistent changes issue.

Hi dswv42!

Many thanks for the time that you’ve spent finding this solution. This is a huge discovery for all MyCloud Gen2 users.

Could you please post an example how to create crontabs tasks with rsync client?

Is it possible with this soluction to activate rsync server (rsync daemon) in the NAS? If so, how it is done?

Best regards.

I’m using My Cloud Gen2, and I found even though those config file can be restored automatically, the process user started won’t be kill by firmware or other sys process. So I wrote a shell script working like a daemon to compare “/var/spool/cron/crontab/root” to my customised crontab file, and reinstall my crontab file if they’re not the same, then sleep one minute for another check. So far it works perfectly for my daily rsync job.

Surprised by this but ignore the marked solution to this thread. This is the correct method for amending the crontab. Immediately rebooting after configuring the xml file fixed the changes into persistent memory.

Thanks Grauwind.

Pops

Ok, I know I’m bringing this one back from the dead but this is for those that find this in a search looking for answers.

After a 4 second reset or maybe even a 40 second admin is no longer the default login. If you created a new admin account, its still there, only the password has been removed. So don’t login in with ‘admin’, login with whatever ID you had before and leave the password field blank.