Subscribe

Get the Network Administrators tool pack

Subscribe to our newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them.

Click Here to get your free tools

Recent Posts

Search

Archives

Windows Cron Service – Version 2.0

Post image for Windows Cron Service – Version 2.0

by Steve Wiseman on May 16, 2012 · 75 comments

in Tips,Tools,Utility


.

Back in November we released a free cron service for windows

What is it?

It is a task scheduler that uses the same format as the unix cron service.

Clock

The motivation for this tool was that the task scheduler built into windows did not have a good way of moving jobs from one computer to another.

With our cron service, you can setup your list of jobs and easily copy the ‘crontab’ file to other servers – the cron service instantly sees the change. No messing around in the registry.

A few problems with 1.0:

-It did not recognize vbs or bat files, so you would have to go through all kinds of trouble to get the command line right

-The logging was not very good, so it was hard to see if a job failed

-All processes executed in the service context. That means you can never run a visual application, and your scripts cannot access network drives.

-No easy way to edit the file – Just notepad.exe. Why not have a nice job editing tool?

With 2.0 we fixed that and more

The first thing we did was add a bunch of execution options. With your job you can:

-Run the job in all active remote desktop sessions

-Run the job in the console session

-Run the job as the current user, or as an administrator

-Run the job in the console, even if no one is logged on. Like this:

Why would you need that?

Think of all the scripts you wish you could run that either need to at least show one small progress window…or access a network drive – even if a user was logged off.

Now with IntelliAdmin Cron 2.0 you can do it.

I bet you are thinking:

“Man that would be cool if remote execute in Network Administrator could do that.”

Yea, we thought so too. All of these options will be added to the Remote Execute action of Network Administrator in a few weeks – Buy it now and it will be a free update.

Included with this version is a crontab edit application. It makes it a breeze to edit your jobs:

Cron Edit Tool

If you forget the crontab format, it has a cheat sheet included…so you don’t have to browse around trying to figure it out:

The new service uses log rotation, so the log files will never threaten to take up too much disk space:

Status.log – List of the latest job runs and the result

Error.log – Any errors encountered are reported here

The service watches the crontab file, so all changes are immediate.

If you want to create the crontab file manually, you can find more about it here

We have made a change to the format (It will accept the old format too) to accommodate our execution options.

A typical line in your crontab will look like this:

* * * * * "c:\temp\test.vbs"

The new format has an integer value right before the path of the program to execute:

* * * * * 121 "c:\temp\test.vbs"

Here are the execution options that make up that value:

1 = The process is executed as an administrator
2 = The process is executed as the session user
4 = The process is hidden when executed
8 = The process is executed in the console session
16 = The process will only be executed if someone is logged into the console
32 = The process will be executed in all RDP sessions.
64 = The will disable the job

If you wanted the program to run as administrator in all the current RDP sessions you would use: 33

This is calculated by adding the options together…32+1

If you wanted the program to run in the console as the current user, but only if someone was logged in, it would be: 2 + 16 + 8 = 26

Finally, we made this app as tight as possible. The service app is a little under 150K. If you want to install it without our setup, just copy the icronsvr.exe to the folder you want it in, and install it like this from the command line:

icronsvr.exe install icronsvr

The second argument is the service name..don’t forget to include that.

If you want to remove it use this:

icronsvr.exe uninstall icronsvr

The crontab edit tool just needs to be run in the same folder as the crontab file, but is not required for its operation.

Finally, this is totally free for commercial and personal use.

Click here to get it now from our download page.

Enjoy the IntelliAdmin software goodnees – and as always no spyware or badware.

One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools

Related Articles:

{ 50 comments… read them below or add one }

1 Jen Minsk May 16, 2012 at 4:26 pm

Thank you! Thank you! Thank you!

This is exactly what I was looking for. When you posted the message that there was going to be an update, I never expected all of this. This is perfect for what I am trying to accomplish with your cron app!

2 Dave May 16, 2012 at 4:28 pm

Hey Steve. Know I am a pain in the ass. Does this work for 2000?

3 Steve Wiseman May 16, 2012 at 4:29 pm

Yes it does…but it does have some limits. I believe that the process launched cannot map network drives under 2000 due to some limitations with the process creation APIs on that platform.

4 Mike Lundquist May 16, 2012 at 5:10 pm

What about Vista, Windows 7. If you set it to execute as the current user, and the current user is an admin. Will it run elevated?

5 Steve Wiseman May 16, 2012 at 5:11 pm

Yes. Just like the Widows Scheduler it will automatically elevate the process without UAC prompting you.

6 Chester May 16, 2012 at 9:52 pm

Well, this is so much win!!! Thank you Steve, this is all i needed!! You guys are just great!!

7 Chester May 16, 2012 at 10:01 pm

As I said, this is awesome, but i wan to ask you a thing. Is it possible to include a option to search the crontab file in another location?
Thank you and continue with the great work!

8 Steve Wiseman May 16, 2012 at 11:35 pm

That will have to be in 2.1 🙂

9 Keith Graber May 17, 2012 at 4:20 pm

Hello! This looks to be a great program! I’ve found an issue though, jobs added by your GUI have all spaces removed in the path and the arguments fields when written to the crontab file, and if the Full Path field was entered manually with quotes (“), then double quotes are entered in crontab.

Thanks again!

10 Keith Graber May 17, 2012 at 4:51 pm

Hello again! (Please don’t post this comment if you don’t want to, but I’m not sure how else to contact you).

I’ve manually corrected the space issue in the crontab file by editing it with Notepad, but the job is failing. I’m suspecting that even though the entry in crontab is correct, when the job is executed by icontsvr the spaces are again being removed.

Thanks!

11 Steve Wiseman May 18, 2012 at 8:22 am

Sounds like a bug. I will have the team take a look at this right away.

Thanks,

Steve

12 Steve Wiseman May 18, 2012 at 8:23 am

Hello Keith,

One question..could you send me an example command line that you are using?

send it to: support@intelliadmin.com

Thanks,

Steve

13 Steve Wiseman May 18, 2012 at 9:10 am

OK Keith,

Thank you so much for reporting this. Our code that was checking the sanity of the hours, min, days, etc…was being used against the filename and the arguments.

We have fixed the issue and uploaded a new version. Here is the download link:

http://www.intelliadmin.com/iadmincron.exe

After the install, go into the settings app and check to make sure it now shows a build number. The build should be 2.1.0.17

14 Arti June 5, 2012 at 9:28 am

Hi,
how add php file on localhost serv.
i try
C:\xampp\htdocs\file.php
http://localhost/file.php

15 Steve Wiseman June 5, 2012 at 12:09 pm

Hello,

The process execution system in Windows will not know where to find PHP.exe so you need to make your filename:

C:\Program Files\PHP.exe

and then your Arguments

c:\xampp\htdocs\file.php

I would test it at the command line first to see if your script is running properly…since php works differently when run this way.

16 Red June 8, 2012 at 2:25 pm

Hi,

Do you have a list of the meaning of error codes from the status log?
I am getting Return Code: 1314

I am testing a simple script on WinXPP to backup data (while logged off) to a Windows network share. Using UNC and IP address for destinatation. Works fine when logged on. Nada when logged off.

Would you mind pointing me in the right direction?

thanks

17 Steve Wiseman June 8, 2012 at 3:30 pm

1314 Is a type of access denied message. I believe that since you are running from the system account when logged off…some versions of windows will not allow access to network shares.

Those return codes are from windows…here is the listing that includes 1314:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms681385(v=vs.85).aspx

I think the only way around this is to have our cron service allow you to specify user accounts…but I don’t know if we will implement this…since there are many security implications. It would require that we store the username and password in a file, and make sure it is encrypted.

18 Red June 8, 2012 at 3:53 pm

Hi Steve,

Thanks for the quick response!
After further testing it appears the destination network share is not accessible. The script runs fine (when logged off) if destination is local.

I am looking for someway of running the backup script using a domain account to backup to a network location.
Will fiddle with it a bit more, but it may not be possible.

Thanks for a cool little product!

Michael

19 Chop June 10, 2012 at 5:15 pm

Can you explain the Return codes a bit please. I’m seeing a RC = 1 and don’t know what that means, but it doesn’t look like my script (.py) ran because I don’t see the changes I see when I run it normally.

My cron job has two parts after the timing info: C:\Python32\python.exe then a space then –full path–\script.py

I’m on Win 7

Thanks

20 Steve Wiseman June 11, 2012 at 9:18 am

That means success. What does your python script do?

That might help us understand why it is failing.

Thanks,

Steve

21 Chop June 12, 2012 at 11:05 am

It’s working now, again with a RC = 1. It was failing because the path in the argument had a space. I put the argument in double quotes and that solved it. Thanks.

Love this product !

22 Steve Wiseman June 12, 2012 at 11:06 am

Great to hear it. Please let us know if you have any more issues – we are happy to help 😉

23 Chop June 12, 2012 at 11:07 am

IT runs a few queries on one table, makes decisions based on business rules and then and inserts some entries in another table. It’s broadcasting and the overall function is to append to a playlist.

24 Steve Wiseman June 12, 2012 at 11:26 am

I see what was happing…it was still returning a 1 since python was executing…but it could not see the full path to your script…so now that you have the quotes it can see the whole path…and still returns a 1 since it is still successfully executing python itself.

25 Simon Rainville July 2, 2012 at 1:09 am

Hello,
It would be nice if we could execute a certain command under a certain user. Because I am planning to do an automatised backup of a remote fileserver with your programm (which is very good for free), but sometimes there is no session which are opened on the computer, so the batch blocks when it wants to map the network drives. I can use psexec (psexec -u user -p password -i “c:\batch.cmd”) which runs my batch under a certain user which has saved credentials, but it would be good if cron can do it natively (with user/pass encrypted if possible), because i have to give my credentials unencrypted in order to use psexec. If it’s too hard to implement because of security, i will understand. Thanks in advance 🙂

26 Steve Wiseman July 3, 2012 at 12:28 am

Hi Simon,

It is not really that hard…but our concern would be that some users would not realize the security implications. We could not truly encrypt the file since that would require a password…where would the password go? Probably right back in that same file!

One way around this would be if we could launch a process using only the username…without a password. This hack was possible prior to Vista using undocumented API calls…but we have not found a way to do it in Vista or higher.

Still I think what we could do is simply obfuscate it (This would be encrypt the password using some type of info that is static within the cron app)…the password would be reversible…but it would take much more effort than if it were clear text. And you could secure it by setting windows permissions on the file.

We will keep this in mind for the next release. Thanks for taking the time to comment.

Steve

27 Simon Rainville July 3, 2012 at 3:12 am

No trouble, if I can help by leaving feedbacks and suggestions 🙂

28 Nils July 10, 2012 at 7:12 am

Hi! Great Work!
But after update to IntelliAdminCron v2 the configuration file is left, where you can set the path to the crontab file?
We need this very urgently…

Best regards

Nils

29 Josh July 11, 2012 at 5:28 pm

Love it so far, but is there any chance that you could add the pid of the process kicked off, as well as when the process is termed to the logs?

30 Pat Flanders August 4, 2012 at 10:08 am

Great job, Steve.

I’m using the original version.

Backs up my data drives on a specified day each month.

Perfect.

Thanks so much for all your time.

31 relinson August 10, 2012 at 1:42 am

This gadget is very useful. I want to know, the same dispatch, the first execution is not over, and the second began, this case is how to deal with? In other words, how to make the task can be the implementation of the serial, rather thanparallel execution?

32 Steve Wiseman August 10, 2012 at 10:45 am

Hello Relinson,

I am not exactly sure what you are looking for, but why not put your list of things to execute in a batch file so they go in order, and then call that bat file from the cron?

33 Dong Hong August 19, 2012 at 11:48 pm

Hi !
How to i use parameter of URL same as http://localhost/sptkeyboot/index.php/bot_run_google/test_runcrob ( use CodeIgniter ) when i add a new tab? What is My Arguments ?
Thank you very much.

34 Steve Wiseman August 20, 2012 at 12:07 pm

Hi Dong,

Not exactly sure what you are trying to do. Do you want cron to hit that web page on the specified interval?

If so, you will need to install something like wget, or curl and then have cron call it with your website as an argument

35 Dong Hong August 21, 2012 at 5:16 am

How to use curl in Windows Cron Service? if it can then you give me example. Thanks

36 Dragan August 26, 2012 at 7:24 pm

Hi! Very useful app!
My question is about logging (Status and Error log file size). Do you plan to add more control over this functionality? What do you mean by “log rotation”? And is it possible to at least turn of logging?

All the best to you and the team, and thanks!

37 Steve Wiseman August 27, 2012 at 1:28 am

Hello Dragan,

We are always making updates to this app..so anything is possible. It just depends on demand. Log rotation is when the log gets to a specific size, and stops growing…it then overwrites the oldest log entries.

We are brainstorming some more updates for this freebie…so I will put your request on the list.

Thanks,

Steve

38 Krzysztof Parjaszewski September 6, 2012 at 2:56 am

Hey Steve,

Great Job!
Is it possible to add a sub-crontable for each specific application?

I am running a dev environment here and it will be great if I could have a specific crontab file for each application not to make one application is messing with another.

Many thanks for Your help,

Krzysztof

39 Krzysztof Parjaszewski September 6, 2012 at 2:57 am

The second question is – can I put a crontab file (or each of the sub-crontab files) in a specific location?

Cheers,
Krzysztof

40 tim liu September 10, 2012 at 10:43 pm

Hi, steve,

This App is awsome. Thank you.
When I use mklink cmd on the crontan file in win7, it could not working. Is this function possible, because I want to put the crontab file on the network drive.

Thanks,

Tim

41 Ullrich September 13, 2012 at 4:54 am

Hi,
the cron-tool was exactly I was looking for. But I can not get it to work. It runs and gives a ReturnCode of 1, but the called Batchfile is not executed.
I do that:
*/1 * * * * 9 “C:\Kopie1.bat” /c
The batch itself runs fine. Any idea whats is going wrong?
Ullrich

42 Steve Wiseman September 13, 2012 at 11:19 am

Hello Ullrich,

What does the logfile say? There is a log file in the same folder as the cron app.

Also, I want to let everyone know we are listening to your requests, and are building a feature list for Windows Cron 3.0…so please be paitent…and post any requests you have to this page.

Thanks,

Steve

43 Ullrich September 14, 2012 at 10:40 am

Hi Steve,

I only see lines like this:
[2012/09/14 – 16:39:00] Executed [C:\WINDOWS\System32\cmd.exe] with arguments [/c “”C:\Kopie1.bat” /c”] Session ID: 0 Return Code: 1

Cheers
Ullrich

44 Steve Wiseman September 14, 2012 at 10:49 am

Hi Ullrich,

It looks like it is executing. Open the cron settings, and set that file to run in the current console session, and put a pause at the end of your bat file…see if there are any errors.

Thanks,

Steve

45 Ullrich September 14, 2012 at 11:00 am

Hi Steve,

ah, it says “can not find the path.”
Could that come from that the source-path is a mapped network-drive?

Kind regards

Ullrich

46 Steve Wiseman September 16, 2012 at 10:27 am

Yes. That would be the problem. What about using a UNC path instead? Or mapping the drive in the script.

Make sure you do not use the system account since it is restricted from using network resources

47 Ullrich September 17, 2012 at 6:00 am

Hi Steve,

I just tried to use UNC-path. Now it says Access denied. But Cron is running as local Admin. Calling the bat works fine for both, UNC and mapped drive

So how is the cron util calling the bat-file? What can I do else?

Cheers

Ullrich

48 Steve Wiseman September 17, 2012 at 9:22 am

Hi Ullrich,

It may not work in its current form. I think one way around it is to have it run as local admin, but in the console session, and hidden. One of the things MS has been doing is locking down the CreateProcess API. In some of the latest patches network sharing has not been working unless you are executing from the current console session.

One way around this is for us to allow you to provide credentials to the cron app…that would solve the issue 100%. We are working on that right now…but it will be a while before the next release.

Steve

49 Ullrich September 17, 2012 at 5:33 pm

Hi Steve,

thanks for your reply. Unfortunately this doesn’t work either. What do you think, when the next release will be available?

Kind regards

Ullrich

50 Chester October 6, 2012 at 5:30 pm

Hello again Steve!

I’m using cron service to run a php script every one hour. It works like a charm if I am logged in the server that cron is running (I access it remotely) but if I logout, the php script doesn’t run.
When I am logged in it works and this two lines are generated in the status log file:
[2012/10/06 – 21:00:00] Executed [C:\PHP\php.exe] with arguments [-q -f “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/deccareims/scripts/EnvioNewsletter.php”] Session ID: 0 Return Code: 1
[2012/10/06 – 21:00:00] Executed [C:\PHP\php.exe] with arguments [-q -f “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/deccareims/scripts/EnvioNewsletter.php”] Session ID: 3 Return Code: 0
but when I am logged off it doesn’t run, and generates just this line:
[2012/10/06 – 22:00:00] Executed [C:\PHP\php.exe] with arguments [-q -f “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/deccareims/scripts/EnvioNewsletter.php”] Session ID: 3 Return Code: 0
Is this an issue of cron service or am I doing something wrong?
Crontab is running as local administrator, and has the options “Execute in the console session” and “Execute in any active RDP session” checked. The server operating system is Windows XP. Any help is welcome! 🙂

Thanks in advance, and congratulations for your great work!!!

Leave a Comment

Category Links - Windows Forum - Exchange Forum