How to create a cron job and run it ,give simpleexample
Hi,
How create a cron job in terminal, and how to run it. Please give a simple example Thanks Ramakrishnan |
A good start would be
http://www.cyberciti.biz/faq/how-do-...-or-unix-oses/ |
Example
Hi Ramakrishnan,
firstly when you want to create/edit your crontab file type the following. Code:
crontab -e Here's a simple example. This line executes the "find" command at 2AM on the 12th of every month that a Sunday or Saturday falls on. Code:
# Minute Hour Day of Month Month Day of Week Command http://www.pantz.org/software/cron/croninfo.html Good Luck |
Hi,
Assumptions: Script you want to run: foo.sh When: daily 12:15 From the terminal: crontab -e (a editor session is started) Add: 15 12 * * * /full/path/to/foo.sh Save and exit editor. Done. Look at man 5 crontab for the explanation of the 15 12 * * * (minutes, hours, monthday, month, weekday ) notation. Hope this helps. |
Hi,
Thanks to all when i type crontab -e on terminal it gives /var/spool/cron/crontabs/node2: Permission denied |
Hi,
You (the user executing the crontab -e command) must have crontab access. I'm not sure if this is true for all distro's but have a look at /etc/cron.allow, the user should be added there (you need root access to change that file). Hope this helps. Oh, just remembered: The user should not be present in /etc/cron.deny. |
in my ubuntu
/etc/cron.allow is not found and also when type sudo su in terminal it shows sudo: must be setuid root and i can't install new packages why? |
Hi,
I'm not an Ubuntu user, but it looks like something was not installed correctly (the setuid thingy). Maybe an Ubuntu user can help you with that one. You can create the /etc/cron.allow yourself (as root). It expects one user per line. Hope this helps. |
Quote:
|
Hi,
From the terminal, as root user: vi /etc/cron.allow Once it opens press i (for insert) and type the username that needs cron access. Press esc (escsape, you will taken out of insertion mode) Press: :wq this will write (w) the file and quit (q), don't forget the leading : Last thing to do is to change the permissions of this file: chmod 600 /etc/deny.allow You can cat the file to see if it is ok: cat /etc/cron.allow. You should see the user that was added. Hope this helps. |
Actually
:wg should be :wq although it's quicker to do :x you'd need to be root to edit cron.allow or cron.deny. In Ubuntu you should be able to do something like sudo su - to become root. If that doesn't work, show us the err msgs you get. /rant I REALLY hate the way Ubuntu has messed with the std sudo & su setup that the rest of the *nix world has always used! end_rant/ |
Hi,
When i type vi/etc/cron.allow result is bash: vi/etc/cron.allow: No such file or directory |
You missed the space between the cmd and the param
vi /etc/cron.allow http://rute.2038bug.com/index.html.gz |
Hi,
when i type vi /etc/cron.allow and pressed i then typed root then esc pressed then i typed :wq then esc it shows "/etc/cron.allow" "/etc/cron.allow" E212: Can't open file for writing why |
Hi,
2 things: 1) You don't need to put the root user in the cron.allow file, root is all powerful. I initially thought you were talking about a normal user. 2) Another way of putting the username into /etc/cron.allow (as root): echo "username" >> /etc/cron.allow After that, just in case: chmod 600 /etc/cron.allow Hope this helps. |
All times are GMT -5. The time now is 08:49 AM. |