How to start my cronjob manually?
Hi!
I would like to know how I may start a cronjob manually? thanks. |
Your cron job scheduled should be some script that you have written for some purpose. Why not run the script manually?
|
Run the content from the cron job's script field in a shell. If your cron job is this (a sample):
* * * * * php /home/me/my.php then run from the command-line the 'php /home/me/my.php' part. Note: some hosted servers would replace 'php /home/me/my.php' with something like '/ramdisk/home/me/php5 /home/me/my.php' or similar - this can be misleading. JD Linux Archive |
xpucto:
The easiest <muy facil> way to start cronjob is to place your script inside the folder --make your choice of job time frequency: hourly, daily, weekly or monthly. Then fix your time on the crontab: # crontab -e <Enter> {for help read manual about crontab: $ man crontab} To find out whether your script goes according to your expectation run it manually first: # /etc/cron.daily/your.script <Enter> If you want to be certain if cron will run it according to crontab, test set it in current time. You will need "reload" or "restart" cron daemon for that, or you want, reboot the system. Then check if your job is running: # ps axu See if your job is among the processes. Sometimes you will need wait few moments before cron starts then try ps axu it again. Goodluck. Hope it helps. |
Use SH to test your Shell Scripts.
If your Cron job is a Linux Shell Script with the ".sh" extension, you could do the following:
[root@localhost ~]# sh /etc/cron.daily/your_script.sh |
This works
I know this is an old post but it worked for me.
Give drupalfever a cookie. I hated when you search and search just to find out that people post these so called fixes and they never work. Thanks drupalfever for a real solution. |
How can I start my cron in owncloud
I'm newbie for cron
I have added a job like this, not sure if it is right though */15 * * * * php /path/to/owncloud/occ files:scan --all I think this should scan all files very 15 minutes, not sure, is that correct? I would like to start it manually to make sure it works How can I run the cron.php from command line? |
The only way to know if cron is going to do something is to use cron to do it.
You can't "manually" do something when you want to test things like the time something is to run... |
I use owncloud on a linux server
I don't know anything about cron but I have added this job below from crontab but it doesn't seem to run sudo -u www-data crontab -e */15 * * * * php /path/to/owncloud/occ files:scan --all ---------------------------> */15 * * * * php /etc/www/owncloud/occ files:scan --all When I go to owncloud admin page I get message: "Last cron was executed at March 24, 2015 at 9:41:15 PM GMT. This is more than an hour ago, something seems wrong" Then I have been asked to run the cron.php from command line But I don't know how to do that, tried running this from the terminal */15 * * * * php /etc/www/owncloud/occ files:scan --all but it didn't work My question is how to run the cron from command line if somebody can help me? |
Quote:
You can run the command line "php /etc/www/owncloud/occ files:scan --all", but you cannot run "cron" from the command line. It is a daemon service, not a command. That is why you use the crontab command to interact with it. |
What you can do is look in /var/log/cron (you may need to be root to do that) and see what happened when (or if) the cron daemon tried to run your job, though in most cases there would have been mail sent to the owner of the crontab if the job failed.
|
If you want to test something in cron, you can get reasonably close by limiting your environment to what cron uses and then running the command.
For example, if the crontab entry you want to test is: Code:
*/15 * * * * php /etc/www/owncloud/occ files:scan --all Code:
env -i bash |
sorry it is var not etc
*/15 * * * * php /var/www/owncloud/occ files:scan --all This is the output carlos@ubuntu:~$ env -i bash carlos@ubuntu:/home/carlos$ export PATH=/usr/bin:/bin php /var/www/owncloud/oc> bash: export: `/var/www/owncloud/occ': not a valid identifier bash: export: `files:scan': not a valid identifier bash: export: `--all': not a valid identifier carlos@ubuntu:/home/carlos$ |
Quote:
I use nano editor sudo -u www-data crontab -e */15 * * * * php /var/www/owncloud/occ files:scan --all Ctrl+O to save then I get back to terminal, and I get installing, that's all I get I don't have a cron.log In Ubuntu I have uncommented this line /etc/rsyslog.d/50-default.conf Find the line that starts with: #cron.* uncomment that line, save the file, and restart rsyslog: sudo service rsyslog restart I got the cron.log now I can attach the file to the system, i get invalid file Any way this is the cron log Apr 5 12:06:03 ubuntu crontab[5410]: (www-data) BEGIN EDIT (www-data) Apr 5 12:06:15 ubuntu crontab[5410]: (www-data) END EDIT (www-data) Apr 5 12:06:18 ubuntu crontab[5424]: (www-data) BEGIN EDIT (www-data) Apr 5 12:08:26 ubuntu crontab[5540]: (www-data) BEGIN EDIT (www-data) Apr 5 12:09:01 ubuntu CRON[5608]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime)) Apr 5 12:15:01 ubuntu CRON[5745]: (www-data) CMD (php /var/www/owncloud/occ files:scan --all) Apr 5 12:17:01 ubuntu CRON[5772]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) |
This is cron UI message in the admin page
Cron Last cron was executed at April 3, 2015 at 10:49:09 PM GMT. This is more than an hour ago, something seems wrong. |
All times are GMT -5. The time now is 06:45 PM. |