# Ubuntu CRON JOB migrate to FreeBSD



## nandinhuuoliveira (Oct 4, 2012)

Hi..

I have a cron job on ubuntu server, however I migrate my app to FreeBSD server and can not make the run cron.

Ubuntu crontab

```
*/15 * * * * /usr/home/websites/vhosts/management/www/protected/yiic ebmanager
```
however I can not set up this cron on FreeBSD.

In /var/log/cron does not appear any error, but I do not I make my application to download an RSS.


----------



## SirDice (Oct 4, 2012)

`$ crontab -e` and paste that line in there.


----------



## mamalos (Oct 4, 2012)

...or you can edit /etc/crontab as well...don't know if it's bad, but I do it all the time . If you decide to use this solution, your entry should be changed to this:


```
*/15 * * * * [B]root[/B] /usr/home/websites/vhosts/management/www/protected/yiic ebmanager
```

or whoever the user is supposed to run this command.


----------



## SirDice (Oct 4, 2012)

mamalos said:
			
		

> ...or you can edit /etc/crontab as well...don't know if it's bad, but I do it all the time .


Leave /etc/crontab alone. If you have to run something as root use crontab -e as root.


----------



## mamalos (Oct 4, 2012)

Why SirDice?

It's much easier to remember it when migrating/upgrading to another machine than root's cron folder. As far as security is concerned, its only problem is that it is readable by anyone -if I am not mistaken-, right?


----------



## SirDice (Oct 4, 2012)

It's more to do with updating. The update process may change /etc/crontab but it will never touch /var/cron/tabs/*.


----------



## mamalos (Oct 4, 2012)

OK, but during upgrading (after running mergemaster(8) which is the real "danger" for this file) one already needs to be careful about some files (/etc/passwd, /etc/master.passwd, /etc/ssh/sshd_config, /etc/hosts and some others); adding one more to my watch list isn't that much of a burden...

And yes, and I do know that this is a very personal opinion I am writing..


----------



## SirDice (Oct 4, 2012)

I don't think freebsd-update(8) will do that. So it's easier/simpler not to touch it. Leave /etc/crontab for system related stuff and put your own stuff in root's crontab(1).


----------



## nandinhuuoliveira (Oct 4, 2012)

mamalos said:
			
		

> ...or you can edit /etc/crontab as well...don't know if it's bad, but I do it all the time . If you decide to use this solution, your entry should be changed to this:
> 
> 
> ```
> ...



So I put this line on user crontab (*sudo crontab -e*), but don't work.

I put again on /etc/crontab and again don't work.

I run this command on shell script and work again

My script file, download a RSS e insert om my database, this script have a screen debug, so I run on crontab include this command

```
>> /var/log/ebmanager_err.log
```
this script have a *chmod 777* to user pftd, and group wheel(same group to root user), but don't work...

I don't more have ideia... 


on crontab this script runinng, and dont appear any error, but my script don't execute success.


----------



## SirDice (Oct 4, 2012)

nandinhuuoliveira said:
			
		

> this script have a *chmod 777* to user pftd, and group wheel(same group to root user), but don't work...


Bad, bad idea. Now any user logging in on your system can modify that file and gain root access. You just gave all your users a backdoor.


----------



## nandinhuuoliveira (Oct 4, 2012)

Correct....

So I put this line on root crontab (*sudo su | crontab -e*), but don't work.

I put again on /etc/crontab and again don't work.
I run this command on shell script and work again.

My script file, download a RSS e insert om my database, this script have a screen debug, so I run on crontab include this command

```
>> /var/log/ebmanager_err.log
```
this script have a chmod 777 to user pftd, and group wheel(same group to root user), but don't work...

I don't more have idea... 


on crontab this script runinng, and dont appear any error, but my script don't execute success.


----------



## SirDice (Oct 4, 2012)

Keep in mind that PATH is fairly limited when running scripts from cron(8).


----------



## mamalos (Oct 4, 2012)

the line with *root* won't work with *crontab -e*, you have to remove root. What are the logs of /var/log/cron. Moreover, what is the second argument you're giving in this command? I hope it's not a file, cause if so it is relative to your current working directory (CWD).


----------



## mamalos (Oct 4, 2012)

SirDice said:
			
		

> Keep in mind that PATH is fairly limited when running scripts from cron(8).



Which implies that you may have to use full path commands inside your script.


----------



## nandinhuuoliveira (Oct 4, 2012)

I'm actually a Windows Administrator Certificate, but the first time I am working with FreeBSD, I have some experience with Ubuntu, and am also a user of Mac OSX, and I know that to change the permission to 777 to open a big security hole.

I'll change the permission for the orignal, but need to make the script run in cron, but I have to run this shell script in every 30min.

This script is an executable php, I tried to create a. sh file and put the php script inside, but still not done downloading my RSS and entering the information into my database.


----------



## nandinhuuoliveira (Oct 4, 2012)

mamalos said:
			
		

> the line with *root* won't work with *crontab -e*, you have to remove root. What are the logs of /var/log/cron. Moreover, what is the second argument you're giving in this command? I hope it's not a file, cause if so it is relative to your current working directory (CWD).




this argumment, is a class on my php


----------



## nandinhuuoliveira (Oct 4, 2012)

mamalos said:
			
		

> Which implies that you may have to use full path commands inside your script.



it may be, I will contact my programmer that made the entire script to put the full path

but because the command is executed in the shell script and not in cron, and put the same command


----------



## nandinhuuoliveira (Oct 4, 2012)

nandinhuuoliveira said:
			
		

> this argumment, is a class on my php



I remembered that the script is encrypted with IonCube and I can not see the source code


----------



## SirDice (Oct 4, 2012)

nandinhuuoliveira said:
			
		

> I remembered that the script is encrypted with IonCube and I can not see the source code


That's rather useless. Anybody can easily reverse it. Think about it, the interpreter needs to be able to read it or it can't execute it. To be able to read it it must be decoded. If the script can decode itself, anybody can decode it.


----------



## nandinhuuoliveira (Oct 4, 2012)

Yes I have the ioncube decrypt, but he is paid for that work ...
I just have to keep the server running and update the application by cron


----------



## nandinhuuoliveira (Oct 4, 2012)

How do I know the script ran correctly?

I see the /var/log/cron, but it only shows the user who executed and full command, hand tells me if it was run entirely as the windows task scheduler that shows me the status of job.


----------



## mamalos (Oct 4, 2012)

how do you know the script did *not* run correctly?


----------

