The server-command tools provides a lot of power to administrators to script and automate a variety of functionality in PaperCut. The server-command tool is documented in the manual in the Tools appendix chapter.
The server-command can be used to adjust user credit on an individual or group basis, enable/disable printers, run backups, perform user syncs, etc. Often an administrator will manually run these commands when required, however there are times when it’s useful to schedule a server-command to run on a regular basis. In this situation, the administrator can use the operating system scheduler to automatically run the task on a regular basis.
Scheduling server-commands on Windows
The Windows Task Scheduler can be used to automate running server-command. The steps below explain this process:
1. Log into the PaperCut server as administrator
2. Create a batch file that contains the server command you wish to run. e.g.
A good place to put the file is within the PaperCut installation under [app-path]\server\custom
3. In your batch file add the command you want to run. e.g.:
cd c:\program files\papercut ng\server\bin\win
server-command.exe disable-printer “printsrv1” “labprinter” “-1”
4. Test your batch file to make sure it works as expected.
5. Use the Windows Task Scheduler under Start->Control Panel->Scheduled Tasks to a new task that runs your batch file on the time you require. Ensure that you setup the task to run as a user that has permission to run “server-command” (i.e. a local administrator).
Note: More information on the Windows Task Scheduler in the Windows help system.
Scheduling server-commands on Mac / Linux / Unix
On the unix-based platforms like Mac and Linux you can use the cron scheduler. cron is a standard system service used to schedule regular jobs/tasks to be performed.
To setup a cron job to run a server-command:
1. Log into the PaperCut server, as an administrator user.
2. Open a shell command prompt (e.g. Terminal on the Mac).
3. Logon as the “papercut” user. This will allow us to schedule the job to run as the “papercut” user. To logon as the “papercut” user, run the following.
sudo su - papercut
4. Edit the “papercut” user’s crontab file. Running the following command will open the “papercut” user’s crontab:
5. Each line of the crontab file defines a scheduled task to run. The 5 numbers preceding the command specify the time the job will be run (minutes, hours, day of month, month and day of week). Some examples are listed below:
To schedule a command to run at 4:10am on the first day of every month:
10 4 1 * * mycommand
To schedule a command to run at 2:30am every day:
30 2 * * * mycommand
To schedule a command to run at 6:00am each Sunday morning: