Use Run as Scheduled to run a command on a repeating schedule, using a cron expression. For example, every day at noon, or every Monday morning.
How scheduling works
With Run as Scheduled, the command runs on its assigned devices and device groups whenever its cron expression says to, as long as the command is active.
Cron format
A cron expression has 5 fields, separated by spaces:
┌───────────── Minute (0–59)
│ ┌─────────── Hour (0–23)
│ │ ┌───────── Day of the month (1–31)
│ │ │ ┌─────── Month (1–12, or JAN–DEC)
│ │ │ │ ┌───── Day of the week (0–6, or SUN–SAT)
│ │ │ │ │
* * * * *
Common examples
Schedule | Cron expression |
Every minute |
|
Every hour, at 30 minutes past |
|
Every day at 5:00 AM |
|
Every day at noon |
|
Every Monday at 5:00 AM |
|
The first of every month at 5:00 AM |
|
Activate the command
A scheduled command only runs when Command Status is on.
When you create the command, turn on Command Status, and assign devices or device groups.
Later, turn on Command Status in the Commands list, or on the command's page.
Check that it's active. On the command's page, the status shows Active, and Running on shows how many devices and device groups it's assigned to, such as 1 Devices or 1 Device Groups. The Devices and Device groups tabs list them.
Run the command now
To run a command without waiting for its schedule, click Run. Online devices get it right away, without waiting for their next check-in. Offline devices run it when they next connect.
See each run's result in the command's report.
Run as the right user
Under Run As, choose who the command runs as:
Option | Runs as | Use for |
System (default) |
| System-wide changes, such as installing apps for every user, or changing system settings |
Local User | The user signed in to the device | Changes to one user's own files and settings. If no one is signed in when the schedule runs, the command doesn't run. |
On macOS and Linux, you can also turn on Run on Swif Admin Account, to run as Swif's administrator account. See Run a Command Script.
System commands don't run in the user's home folder. On a Mac, a System command runs as root, so its home folder is /var/root, not the user's. Apps that install into the user's home folder, such as extensions for Cursor, VS Code, or browser profiles, fail, often with EACCES: permission denied.
To change a user's files from a System command, for example, when no one may be signed in for a Local User command, run that part as the signed-in user, with sudo -H -u. The -H sets the home folder to the user's own, such as /Users/jane:
loggedInUser=$(stat -f%Su /dev/console)
sudo -H -u "$loggedInUser" <command>
Without -H, the command still uses root's home folder, and fails the same way.
Troubleshooting
The schedule doesn't run
Check that Command Status is on.
If Run As is Local User, check that someone is signed in to the device at the scheduled time.
Check that Running on shows the devices or device groups you assigned.
Check that the devices are online at the scheduled time.
Check the cron expression.
Running on shows 0 Devices, or 0 Device Groups
The command has no devices or groups assigned. Open it, assign them again, and check the Devices and Device groups tabs. If they're still empty, contact Swif support.
A script fails with "permission denied" in /var/root
The command runs as System, so it uses root's home folder. Run that part of the script with sudo -H -u "$loggedInUser", or set Run As to Local User. See Run as the right user.
A script installed an app, but the device's app list doesn't show it yet
Apps installed by Swif show right away. Apps installed another way, such as by your own script, appear when Swif next refreshes the device's app list. See Swif Data Refresh Guide.
Related resources


