| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 105207 | 2009-11-23 07:50:00 | Ubuntu - crontab | WarNox (8772) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 832728 | 2009-11-23 07:50:00 | Hey! I have a script I'm trying to get to run automatically, just for testing purposes . The script is: #!/bin/bash echo "to_file" >> /etc/cron . d/testtext My 'crontab -e' output: # m h dom mon dow command * * * * * root /etc/cron . d/test . sh Basically nothing happens and I cannot find any logs for cron in /var/logs/ . . . If I run the script manually ' . /test . sh' it works fine and puts a line 'to_file' into the 'testtext' file . If I put 'echo "to_file" >> /etc/cron . d/testtext' directly into 'crontab' it works fine . Anyone have any ideas? Thanks in advance, Gregor |
WarNox (8772) | ||
| 832729 | 2009-11-23 10:12:00 | You are trying to run "root" with the argument "/etc/cron.d/test.sh" try: # m h dom mon dow command * * * * * /etc/cron.d/test.sh Also: -Run cron jobs as a normal user if possible. -You don't need to put the jobs in cron.d use /home/user/bin or /root/bin |
Dannz (1668) | ||
| 832730 | 2009-11-23 20:01:00 | I 2nd that. The style you've used in your "crontab -e" line is intended only for the global crontab file (/etc/crontab) to let the system know what user to run the script under. I think using /etc/crontab is discouraged (?) these days anyway (jobs running for a particular user should use their own crontab file). |
MushHead (10626) | ||
| 832731 | 2009-11-23 21:45:00 | The reason I wanted to run it as root is that the actual script I want scheduled has a command that needs root privileges to run. I do not want to be prompted for password since this is meant to be automated :) I did remove the 'root' part from the file and now it seems to be running. Thanks for your help, I didn't realise that the syntax for the global crontab file and 'crontab -e' was different. |
WarNox (8772) | ||
| 1 | |||||