Crontab on MyCloud EX2

Hi,

I got a MyCloud EX2. Now I like to get some date periodly refreshed. For that I like to use a cronjob. But if I add somethin to the Cronjob it get deleted after some hours. What can I do against that?

Benjamin

1 Like

Welcome to the Community.

How have you tried so far in order to prevent the Cronjob from being deleted?

Thanks for your answer. What do you mean? I donā€™t know what you want to tell me.

Found a good working Workaround on this ā– ā– ā– ā–  Device. I created a new User with adduser, then created a Crontab File for this user and this works great. Only the File Permissions are a little Problem. But with little bit Linux Skills this Problems are goneā€¦ :slight_smile:

a predictable and reliable way of refreshing content on the EX2 is required via crontab.Ā  Here are a few linux suggestions if you donā€™t know the command line very well.Ā Ā  1) export EDITOR viĀ Ā Ā Ā Ā  sets your favorite editor for editing the crontab. I assume the additional user has already been created then you can add or edit the userā€™s crontab 2) crontab -u USERNAME -eĀ Ā Ā  (edits the crontab)Ā  3) crontab -u USERNAME -lĀ Ā  (lists the crontab for that user).

Everything is removed after reboot, even the new created user account.
Is there any way to fix it?

mapawd wrote:

Everything is removed after reboot, even the new created user account.
Is there any way to fix it?

User accounts created from EX2ā€™s dashboard should be persistent.

And user accounts created directly in the shell (bypassing the dashboard) are not deleted. You can confirm by looking at /etc/passwd file after a reboot. Just those usersā€™ home directories are deleted after reboot. In fact entire /home tree is deleted (as is the entire /etc tree). You can backup the userā€™s home directory in /usr/local/config/ - this folder is the persistent settings storage location. and after reboot, youā€™ll have to manually bring back the userā€™s home directory. But the space in this directory is quite limited (approx 11MB free), so donā€™t store too much stuff in that directory, or else youā€™ll quickly hit the capacity and run into unexpected issues.

Unless you are willing to void your warranty and have the skills to compile the firmware with modded startup script from the source code provided on WDā€™s site, you will have to rely on manual restore of the home directories.

I added my cronjobs to /usr/local/config/config.xml like this

<add_backup
<item id=ā€œ1ā€
<method 3</method
<1></1
<2>
</2
<3></3
<4>
</4
<5>*</5
<run usb_backup -a Filmy -c jobrun</run
</item
</add_backup

it persists even over restart

edit: I canā€™t insert the code here, there are missing > after each line

can you explain whatā€™s the config.xml for and how often will it run the command?

That file is there by default, you just add there your jobs. How often it will run depends on how you set it.

i seeā€¦but how do you set it?

instead of <add_backup i add something i invent like <add_autodelete

instead of <run usb_backup -a Filmy -c jobrun</run i put < run 0 * * * * /opt/bin/find ā€¦ </run something like this?

what exactly are you trying to do?

Finally i read better this postā€¦

You probably will want to try this (at your own risk)ā€¦ Itā€™s just what I did and it works. Even after reboots.

Go to /usr/local/config and edit the config.xml file by adding an entry in the section of the XML.

  1. Add an entry to the crond/list. This basically list number of cron jobs to be added. See mine below, I added surveillance to the list. You must also alter the number of jobs in , but this looks like you have to enter the count - 1 instead. I donā€™t know why. But it would work.

Now i understand better seeing the layout of my config.xml i just donā€™t understand what does he meam saying ā€œbut this looks like you have to enter the count - 1 instead. I donā€™t know why. But it would work.ā€

Iā€™m just trying to add a couple of cronjobs

Iā€™ll take a look on that file when Iā€™m home, but I donā€™t think I had done anything with count, I just added new entries

that sounds nice,
however i added a couple of entries and rebootedā€¦the device wasnā€™t anymore accessible form the networkā€¦
Iā€™ve performed the 40sec reset
firmware: 2.11.157

Maybe itā€™s because i added a couple of new entries other user the other users put an entry in the middle of the listā€¦

i solved installing Transmission using it to launch a script adding crontab entriesā€¦ but i still would like to know also the config.xml method betterā€¦ that could be useful too

This is how my crond part of config.xml looks like

these 4 entries were added by me:
usb_backup -a Backup -c jobrun
usb_backup -a Filmy -c jobrun
usb_backup -a installers -c jobrun
usb_backup -a Serialy -c jobrun

https://www.dropbox.com/s/adsnymux2t3t9k0/config.xml?dl=0

Unfortunately after a certain time my job i created using the startup script of transmission got deleted from crontab i donā€™t know exactly when or why but iā€™d like to know more about the other cronjobs who may have caused thisā€¦ any ideas?

Thanks for your config.xmlā€¦
is there any reason why you put your job in the middle of the list?
Let me try that

It doesnā€™t matter whether you put it in the middle or at the end etc., it automatically sorts on restart. Also remember that there are also other settings in config.xml, I put here only ā€œcrondā€ part of it. Thereā€™s where you should do the changes, donā€™t change other settings.

i tried again but my cloud ex2 fw: 2.11.157 do not boot properly anymore with a custom config.xml

I know this is a year-old thread, but adding some info from my experience. Editing the config.xml worked to add my custom job to crontab and survived a reboot without taking down my unit. I think there may be some critical guidance missing from this post. There are a few characters that are commonly used in terminal commands that conflict with xml characters, for example less than (<), greater than (>), and ampersand (&), among a few others. These characters must be ā€˜escapedā€™ in order to live inside the xml file without ā€˜corruptingā€™ it. Even this forum has problems with these characters as evidenced by the missing less-than (<) symbols in previous posts. You can do this manually if you like (and have experience with xml escaping), but itā€™s probably much simpler to run it through a function to escape it automatically (to prevent human error if nothing else). One such tool is here:

Just paste your command line in there and copy the result to then paste into the <run> element as described above.
Hopes this helps someone else.