Syntax of crontab File Entries. Displaying crontab Files. How to Display a crontab File. Removing crontab Files. How to Remove a crontab File. Controlling Access to the crontab Command. How to Deny crontab Command Access. How to Verify Limited crontab Command Access. Using the at Command Task Map. Scheduling a Single System Task at. Description of the at Command. Controlling Access to the at Command.
How to Create an at Job. How to Remove at Jobs. How to Deny Access to the at Command. Managing System Crash Information Tasks. Managing Core Files Tasks. Troubleshooting System and Software Problems Tasks. The simplest way to create a crontab file is to use the crontab -e command. This command invokes the text editor that has been set for your system environment. If this variable has not been set, the crontab command uses the default editor, ed. Preferably, you should choose an editor that you know well.
The following example shows how to determine if an editor has been defined, and how to set up vi as the default. This allows you to quit without saving changes. Exiting the file and saving changes at this point would overwrite an existing crontab file with an empty file. Add command lines to the file, following the syntax described in "Syntax of crontab File Entries".
The following command entry added to a new crontab file will automatically remove any log files from the user's home directory at am every Sunday morning.
For example, the following display shows that crontab files exist for users smith and jones. Verify the contents of user's crontab file by using crontab -l as described in "How to Display a crontab File". Connect and share knowledge within a single location that is structured and easy to search. I am trying to automate the refreshing of awstats for my webserver and understand that I need to use cron to set that up.
So each user has a crontab file? That file already has some information in it. Is this the main crontab file or something? I have seen some instructions online to use the file that pops up with crontab -e. If I schedule a task as my non-root user, will it run by itself at the time interval as specified, with no issues? Will I need to restart the server after saving the cron job in the crontab file before it will start working?
As a principle, it is best to run scheduled tasks with the lowest privileges you can get away with, so if what you are doing will not require root, don't use root.
If you don't even need to be able to access your account's files and folders, then you can create a new user and use that user account only for that task. This can all be done without superuser permission. If you did edit the crontab file directly I don't know what the result would be. It's possible it simply wouldn't take effect until next restart and any errors may be hard to debug. As you are a newbie as you say, I'd recommend to use nano, it's the simplest editor to use. So if your script needs to be root or a special user, make sure to su to that user and add the cronjob there.
Yes I said it. You always have to make sure that you tell cron where it can find the files and directories. Of course it will run on it's own, that's what it's there for. But you need to check that cronjob really does it, or if it's missing something. And NO, a restart is not needed. A restart with linux is normally only needed, if you install a new kernel.
For it to use you'd need to reboot. Almost everything else can be done without reboot in Linux. Of course there are exceptions, but in general this statement is correct.
0コメント