Setting up a Cron

I set up a script to move my .dng files to my SD card and I would like to set it to Cron, However, as looking on the internet did not lead to very satisfactory answers I decided to ask here “How do I put something into Cron?”
Thanks

You might be better off using the postprocess script to move a .dng file at the time of creation, rather than polling every X minutes to move them. To answer the question though …

You schedule something using cron by adding a line to a file. The file depends on whether you are using

  • the system wide crontab file (/etc/crontab), or
  • the per-user crontab file (/var/spool/cron/crontabs/$USER) where $USER is replaced by your username (presumably purism).

The exact syntax in the file depends on which file. Specifically, the system wide crontab file has an extra field to specify the user that the scheduled job will run under. The required syntax is very briefly documented in the file. See also man 5 crontab for more comprehensive documentation.

So to use the system wide crontab file to move purism's stuff every 10 minutes you would want to add a line looking like

*/10 * * * * purism /home/purism/move_my_stuff

Where obviously you write that script, make it executable and, for your specific requirement as stated, you make sure that the uSD card is mounted already and you know where it is mounted (or otherwise handle the possibility that the uSD card is not there).

To edit the system wide crontab file you of course need to be root so you want something like

sudo vi /etc/crontab

in order to add in the required line and to maintain it in the future if your exact requirements change.

1 Like