can we pass parameter to crontab jobs?

Posted on 2005-04-12
Last Modified: 2013-12-27

We want to pass a parameter to the script, which is scheduled as cron job. It looks like the parameter is not taken. Any suggestion? Thanks

45 06 * * 1-5 su - bgaaip -c sai_inventory_daily AAIP > sai_inventory_daily.log 2>&1
Question by:ebi168
    LVL 20

    Accepted Solution

    Use double-quotes to enclose the command you are passing to 'su'
    su - bgaaip -c "sai_inventory_daily AAIP"

    Author Comment

    let me try it.
    LVL 10

    Expert Comment

    if it's missinterpreted inside crontab then put your command into a script and start your script in your crontab.

    Howevery what you do above does not make to much sense to me... why do you su from root to bgaaip and dont start the command directly in bgaaip's crontab ?

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
    Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now