You are here
Bob - Fri, 2019/08/16 - 11:48
Hi everyone,
I had to reinstall my WordPress TurnKey.
I see in the Webmin webinterface the Cron job like for exemple :
How can I view/edit this cron job ? see what everyline does and how remove a line ? Thank you
Forum:
TBH, I'm not sure how to do this in Webmin
I'm not clear how (or even if) Webmin allows you to adjust those individual jobs. But it's super easy from the commandline! There are a number of relatively straight forward commandline tools that will allow you to view and manipulate cron jobs. :)
As you've possibly already guessed, cron jobs that run hourly, daily, weekly or monthly are found in a relevant /etc/cron.{timeframe}/ directory. Whether or not they run, depends on whether they are executable or not (denoted by the 'x' bit being set, or not). So to view all the daily jobs (both those that will run and those that are disabled) you can use ls (tool to list directories and their contents). The -l switch shows the files in "long list format", which is helpful in this case. It's also worth noting that by default on TurnKey the files are color coded, which makes finding executables (in the case of cron; enabled jobs) extra easy (they're in green). E.g. on my laptop (running Debian Stretch; the basis of TurnKey v15.x):
Returns (note I adjusted the colors a little for improved readability on a light background):
All the jobs in green (and the google-chrome one in cyan in my case; which is a symlink to an executable cron job file elsewhere) are "enabled" and will run whenever cron runs it's daily jobs (IIRC by default, it's usually 4-6am but can be adjusted). The job not colored ('polipo' in my case) is disabled.
To adjust whether a cron job will run or not, simply adjust the executable bit (the 'x's in the far left column). To do that, use chmod. To disable a cron job, remove the executable bit (-x), to enable a cron job, add the executable bit ('+x'). For example to disable, then re-enable my keybase cron job:
Generally cron jobs have (or at least should have) relatively useful names. E.g. 'tklbam-backup' is the automated daily backup job for tklbam, 'logrotate' is the daily cron job that rotates logs, etc. Although obviously how useful that is will depend on how familiar you are with your system and the software installed. Google might assist if you're unsure.
To view the contents of a file (e.g. to see what a particular cron job does), use cat like this:
In this case, it's a simple shell script which sleeps for a random time and does a tklbam-backup. Note that as cron runs in a limited environment, all these scripts should be shell scripts (i.e. have a #!/bin/sh shebang on the first line). Because of the limited cron environment, it's often a good idea to provide the full path to the executable you plan to run (although as per the tklbam example, that isn't required if you know that it will be in the cron system path).
Unless it's a custom cron job that you created, or you know exactly what you are doing, editing cron jobs is generally not recommended. However, if you do wish to edit one, then you can use your preferred commandline text editor. Personally I prefer 'vim' but 'nano' is probably more intuitive for Windows users. (vim users please note, on TurnKey you'll probably want to install "proper" vim, rather than use vim-tiny which is installed by default). To edit a file with nano (or substitute your preferred text editor):
If you wish to change the frequency of a cron job, simply move it to the relevant directory. E.g. to run TKLBAM hourly rather than daily:
If you need more fine grained control of when a cron job runs, you'll need to go a different path. But I think I'll leave it there in the hope I haven't already overwhelmed you with commandline awesomeness! :)
If you have questions and/or would like me to elaborate on anything, please ask. Feel free to give specific examples of what you're trying to achieve.
Add new comment