Tutorial / TL;DR

  1. Requirement: install Termux (F-droid). The following commands are written in the Termux console.
  2. Install the cronie package.
1
pkg install cronie
  1. Install the termux-services package.
1
pkg install termux-services
  1. Restart Termux.
  2. Launch the service (this avoids the sv-enable crond fail: crond: unable to change to service directory: file does not exist message).
1
sv-enable crond
  1. Authorize Termux to access files.
1
termux-setup-storage
  1. Create a new cronjob.
1
* * * * * mv /storage/self/primary/DCIM/Camera/* /storage/self/primary/Pictures/phone

Here, we are moving all the pictures taken with the camera app to a custom folder every minute.

  1. Make sure the service starts on Boot by following the official Termux:Boot tutorial. It does not work for me, but maybe it will for you. In any case, services are started automatically when one launches Termux.

Why?

Using a GCam port to take pictures is nice and all, but it is not possible to change the default folder used to save all the photos (it seems only the RAW folder is configurable). Hence, I wanted a transparent and automatic way to move my pictures from the default folder into a custom one.

Coming from Linux and not wanting to install a random Android app only for this, I looked for solutions leveraging a cronjob. Many internet users hinted at busybox (or Toybox), but it either didn’t include crontab or often required to root the phone (translation: the first installer I tried asked for root access; I rage quitted).

Note that you can create basically any cronjob you want, not only move files around. Have fun, get freaky.

  • F-droid: an alternative Android applications store to the PlayStore, more privacy-friendly and open source.
  • Cronie: based on the original crond, runs jobs asynchronously (source: Arch’s wiki.
  • Termux: a terminal emulator for Android, aka allows you to interact with your phone by typing commands. Comes with a lot of utilities (such as a package manager we use in this post).
  • termux-services: as the name suggest, this package is used to run daemons more easily. In our case, it helps managing the cronie/crond service, which basically starts after the Android boot up, and makes sure the task is actually ran every minute.
  • crontab.guru is one of the many resources helping with the syntax of a cronjob.

Tested on

  • Android: 12
  • Termux: 0.118.0
  • Cronie: 1.6.1